private void logUnusedProperties(Map<String, Object> unsetProperties, ServiceInfo info) { for (String property : unsetProperties.keySet()) { //TODO: DMB: Make more robust later if (property.equalsIgnoreCase("properties")) return; if (property.equalsIgnoreCase("transactionManager")) return; if (info.types.contains("javax.mail.Session")) return; //--- logger.getChildLogger("service").warning("unusedProperty", property, info.id); } }
private static void unusedProperty(final String id, final Logger parentLogger, final String property) { parentLogger.getChildLogger("service").warning("unusedProperty", property, id); }
public JtaEntityManager(final String unitName, final JtaEntityManagerRegistry registry, final EntityManagerFactory entityManagerFactory, final Map properties, final boolean extended) { if (registry == null) { throw new NullPointerException("registry is null"); } if (entityManagerFactory == null) { throw new NullPointerException("entityManagerFactory is null"); } this.unitName = unitName; this.registry = registry; this.entityManagerFactory = entityManagerFactory; this.properties = properties; this.extended = extended; logger = unitName == null ? baseLogger : baseLogger.getChildLogger(unitName); final String wrapConfig = ReloadableEntityManagerFactory.class.isInstance(entityManagerFactory) ? ReloadableEntityManagerFactory.class.cast(entityManagerFactory).getUnitProperties().getProperty("openejb.jpa.query.wrap-no-tx", "true") : "true"; this.wrapNoTxQueries = wrapConfig == null || "true".equalsIgnoreCase(wrapConfig); }
private static void unusedProperty(final String id, final Logger parentLogger, final String property) { if (isInternalProperty(property)) { return; } final String msg = "unused property '" + property + "' for resource '" + id + "'"; if (null != parentLogger) { parentLogger.getChildLogger("service").warning(msg); } else { // note: we should throw an exception if this is called, shouldnt be possible in our lifecycle System.out.println(msg); } }
@Override public void run() { try { stopImpl(); } catch (final Throwable t) { Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQResourceAdapter.class).getChildLogger("service").error("ActiveMQ shutdown failed", t); } } };
@Override public void run() { try { stopImpl(); } catch (final Throwable t) { Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQResourceAdapter.class).getChildLogger("service").error("ActiveMQ shutdown failed", t); } } };
public void createExternalContext(final JndiContextInfo contextInfo) throws OpenEJBException { logger.getChildLogger("service").info("createService", contextInfo.service, contextInfo.id, contextInfo.className); final InitialContext initialContext; try { initialContext = new InitialContext(contextInfo.properties); } catch (final NamingException ne) { throw new OpenEJBException(String.format("JndiProvider(id=\"%s\") could not be created. Failed to create the InitialContext using the supplied properties", contextInfo.id), ne); } try { containerSystem.getJNDIContext().bind("openejb/remote_jndi_contexts/" + contextInfo.id, initialContext); } catch (final NamingException e) { throw new OpenEJBException("Cannot bind " + contextInfo.service + " with id " + contextInfo.id, e); } // Update the config tree config.facilities.remoteJndiContexts.add(contextInfo); logger.getChildLogger("service").debug("createService.success", contextInfo.service, contextInfo.id, contextInfo.className); }
public void createExternalContext(JndiContextInfo contextInfo) throws OpenEJBException { logger.getChildLogger("service").info("createService", contextInfo.service, contextInfo.id, contextInfo.className); InitialContext result; try { InitialContext ic = new InitialContext(contextInfo.properties); result = ic; } catch (NamingException ne) { throw new OpenEJBException("The remote JNDI EJB references for remote-jndi-contexts = " + contextInfo.id + "+ could not be resolved.", ne); } InitialContext cntx = result; try { containerSystem.getJNDIContext().bind("openejb/remote_jndi_contexts/" + contextInfo.id, cntx); } catch (NamingException e) { throw new OpenEJBException("Cannot bind " + contextInfo.service + " with id " + contextInfo.id, e); } // Update the config tree config.facilities.remoteJndiContexts.add(contextInfo); logger.getChildLogger("service").debug("createService.success", contextInfo.service, contextInfo.id, contextInfo.className); }
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 void createConnectionManager(final ConnectionManagerInfo serviceInfo) throws OpenEJBException { final ObjectRecipe serviceRecipe = createRecipe(Collections.<ServiceInfo>emptyList(), serviceInfo); final Object object = props.get("TransactionManager"); serviceRecipe.setProperty("transactionManager", object); final Object service = serviceRecipe.create(); logUnusedProperties(serviceRecipe, serviceInfo); final Class interfce = serviceInterfaces.get(serviceInfo.service); checkImplementation(interfce, service.getClass(), serviceInfo.service, serviceInfo.id); bindService(serviceInfo, service); setSystemInstanceComponent(interfce, service); getContext().put(interfce.getName(), service); props.put(interfce.getName(), service); props.put(serviceInfo.service, service); props.put(serviceInfo.id, service); // Update the config tree config.facilities.connectionManagers.add(serviceInfo); logger.getChildLogger("service").debug("createService.success", serviceInfo.service, serviceInfo.id, serviceInfo.className); }
private ObjectRecipe createRecipe(ServiceInfo info) { Logger serviceLogger = logger.getChildLogger("service"); serviceLogger.info("createService", info.service, info.id, info.className); String[] constructorArgs = info.constructorArgs.toArray(new String[info.constructorArgs.size()]); ObjectRecipe serviceRecipe = new ObjectRecipe(info.className, info.factoryMethod, constructorArgs, null); serviceRecipe.allow(Option.CASE_INSENSITIVE_PROPERTIES); serviceRecipe.allow(Option.IGNORE_MISSING_PROPERTIES); serviceRecipe.setAllProperties(info.properties); if (serviceLogger.isDebugEnabled()){ for (Map.Entry<String, Object> entry : serviceRecipe.getProperties().entrySet()) { serviceLogger.debug("createService.props", entry.getKey(), entry.getValue()); } } return serviceRecipe; }
public void createProxyFactory(final ProxyFactoryInfo serviceInfo) throws OpenEJBException { final ObjectRecipe serviceRecipe = createRecipe(Collections.<ServiceInfo>emptyList(), serviceInfo); final Object service = serviceRecipe.create(); logUnusedProperties(serviceRecipe, serviceInfo); final Class interfce = serviceInterfaces.get(serviceInfo.service); checkImplementation(interfce, service.getClass(), serviceInfo.service, serviceInfo.id); ProxyManager.registerFactory(serviceInfo.id, (ProxyFactory) service); ProxyManager.setDefaultFactory(serviceInfo.id); bindService(serviceInfo, service); setSystemInstanceComponent(interfce, service); getContext().put(interfce.getName(), service); props.put(interfce.getName(), service); props.put(serviceInfo.service, service); props.put(serviceInfo.id, service); // Update the config tree config.facilities.intraVmServer = serviceInfo; logger.getChildLogger("service").debug("createService.success", serviceInfo.service, serviceInfo.id, serviceInfo.className); }
public void createProxyFactory(final ProxyFactoryInfo serviceInfo) throws OpenEJBException { final ObjectRecipe serviceRecipe = createRecipe(serviceInfo); final Object service = serviceRecipe.create(); logUnusedProperties(serviceRecipe, serviceInfo); final Class interfce = serviceInterfaces.get(serviceInfo.service); checkImplementation(interfce, service.getClass(), serviceInfo.service, serviceInfo.id); ProxyManager.registerFactory(serviceInfo.id, (ProxyFactory) service); ProxyManager.setDefaultFactory(serviceInfo.id); bindService(serviceInfo, service); setSystemInstanceComponent(interfce, service); getContext().put(interfce.getName(), service); props.put(interfce.getName(), service); props.put(serviceInfo.service, service); props.put(serviceInfo.id, service); // Update the config tree config.facilities.intraVmServer = serviceInfo; logger.getChildLogger("service").debug("createService.success", serviceInfo.service, serviceInfo.id, serviceInfo.className); }
public void createProxyFactory(ProxyFactoryInfo serviceInfo) throws OpenEJBException { ObjectRecipe serviceRecipe = createRecipe(serviceInfo); Object service = serviceRecipe.create(); logUnusedProperties(serviceRecipe, serviceInfo); Class interfce = serviceInterfaces.get(serviceInfo.service); checkImplementation(interfce, service.getClass(), serviceInfo.service, serviceInfo.id); ProxyManager.registerFactory(serviceInfo.id, (ProxyFactory) service); ProxyManager.setDefaultFactory(serviceInfo.id); bindService(serviceInfo, service); setSystemInstanceComponent(interfce, service); getContext().put(interfce.getName(), service); props.put(interfce.getName(), service); props.put(serviceInfo.service, service); props.put(serviceInfo.id, service); // Update the config tree config.facilities.intraVmServer = serviceInfo; logger.getChildLogger("service").debug("createService.success", serviceInfo.service, serviceInfo.id, serviceInfo.className); }
private void stopImpl() throws Exception { super.stop(); final Collection<BrokerService> brokers = ActiveMQFactory.getBrokers(); final Iterator<BrokerService> it = brokers.iterator(); while (it.hasNext()) { final BrokerService bs = it.next(); try { bs.stop(); bs.waitUntilStopped(); } catch (final Throwable t) { //Ignore } it.remove(); } stopScheduler(); Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQResourceAdapter.class).getChildLogger("service").info("Stopped ActiveMQ broker"); }
private void stopImpl() throws Exception { super.stop(); final Collection<BrokerService> brokers = ActiveMQFactory.getBrokers(); final Iterator<BrokerService> it = brokers.iterator(); while (it.hasNext()) { final BrokerService bs = it.next(); try { bs.stop(); bs.waitUntilStopped(); } catch (final Throwable t) { //Ignore } it.remove(); } stopScheduler(); Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQResourceAdapter.class).getChildLogger("service").info("Stopped ActiveMQ broker"); }
@Override public NetworkConnector addNetworkConnector(final URI discoveryAddress) throws Exception { final NetworkConnector connector = new DiscoveryNetworkConnector(discoveryAddress); try { // try to set properties to broker too final Map<String, String> props = URISupport.parseParameters(discoveryAddress); if (!props.containsKey("skipConnector")) { IntrospectionSupport.setProperties(connector, props); } } catch (final URISyntaxException e) { // low level cause not supported by AMQ by default Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQ5Factory.class).getChildLogger("service") .debug(e.getMessage()); } return addNetworkConnector(connector); } };
private void createInternalBroker(final String brokerXmlConfig, final Properties properties) { ActiveMQFactory.setThreadProperties(properties); try { //The returned broker should be started, but calling start is harmless. //We do not need to track the instance as the factory takes care of this. ActiveMQFactory.createBroker(URLs.uri(getBrokerXmlConfig())).start(); } catch (final Exception e) { Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQResourceAdapter.class).getChildLogger("service").fatal("Failed to start ActiveMQ", e); } finally { ActiveMQFactory.setThreadProperties(null); // reset brokerXmlConfig if (brokerXmlConfig != null) { setBrokerXmlConfig(brokerXmlConfig); } } }
private void createInternalBroker(final String brokerXmlConfig, final Properties properties) { ActiveMQFactory.setThreadProperties(properties); try { //The returned broker should be started, but calling start is harmless. //We do not need to track the instance as the factory takes care of this. ActiveMQFactory.createBroker(URLs.uri(getBrokerXmlConfig())).start(); } catch (final Exception e) { Logger.getInstance(LogCategory.OPENEJB_STARTUP, ActiveMQResourceAdapter.class).getChildLogger("service").fatal("Failed to start ActiveMQ", e); } finally { ActiveMQFactory.setThreadProperties(null); // reset brokerXmlConfig if (brokerXmlConfig != null) { setBrokerXmlConfig(brokerXmlConfig); } } }