org.apache.cxf.common.logging.LogUtils Java Examples

The following examples show how to use org.apache.cxf.common.logging.LogUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoggingOutInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testFormatting() throws Exception {
    control.replay();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintWriter pw = new PrintWriter(baos);

    LoggingOutInterceptor p = new LoggingOutInterceptor(pw);
    //p.setPrettyLogging(true);
    CachedOutputStream cos = new CachedOutputStream();
    String s = "<today><is><the><twenty> <second> <of> <january> <two> <thousand> <and> <nine></nine> "
        + "</and></thousand></two></january></of></second></twenty></the></is></today>";
    cos.write(s.getBytes());
    Message message = new MessageImpl();
    message.setExchange(new ExchangeImpl());
    message.put(Message.CONTENT_TYPE, "application/xml");
    Logger logger = LogUtils.getL7dLogger(this.getClass());
    LoggingOutInterceptor.LoggingCallback l = p.new LoggingCallback(logger, message, cos);
    l.onClose(cos);
    String str = baos.toString();
    //format has changed
    assertFalse(str.matches(s));
    assertTrue(str.contains("<today>"));
}
 
Example #2
Source File: BusFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new BusFactory
 *
 * @param className The class of the BusFactory to create. If null, uses the default search algorithm.
 * @return a new BusFactory to be used to create Bus objects
 */
public static BusFactory newInstance(String className) {
    if (className == null) {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        className = getBusFactoryClass(loader);
        if (className == null && loader != BusFactory.class.getClassLoader()) {
            className = getBusFactoryClass(BusFactory.class.getClassLoader());
        }
    }
    if (className == null) {
        className = BusFactory.DEFAULT_BUS_FACTORY;
    }

    try {
        Class<? extends BusFactory> busFactoryClass = ClassLoaderUtils.loadClass(className, BusFactory.class)
            .asSubclass(BusFactory.class);

        return busFactoryClass.getConstructor().newInstance();
    } catch (Exception ex) {
        LogUtils.log(LOG, Level.SEVERE, "BUS_FACTORY_INSTANTIATION_EXC", ex);
        throw new RuntimeException(ex);
    }
}
 
Example #3
Source File: AbstractLoggingInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
Logger getMessageLogger(Message message) {
    if (isLoggingDisabledNow(message)) {
        return null;
    }
    Endpoint ep = message.getExchange().getEndpoint();
    if (ep == null || ep.getEndpointInfo() == null) {
        return getLogger();
    }
    EndpointInfo endpoint = ep.getEndpointInfo();
    if (endpoint.getService() == null) {
        return getLogger();
    }
    Logger logger = endpoint.getProperty("MessageLogger", Logger.class);
    if (logger == null) {
        String serviceName = endpoint.getService().getName().getLocalPart();
        InterfaceInfo iface = endpoint.getService().getInterface();
        String portName = endpoint.getName().getLocalPart();
        String portTypeName = iface.getName().getLocalPart();
        String logName = "org.apache.cxf.services." + serviceName + "."
            + portName + "." + portTypeName;
        logger = LogUtils.getL7dLogger(this.getClass(), null, logName);
        endpoint.setProperty("MessageLogger", logger);
    }
    return logger;
}
 
Example #4
Source File: SSLUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static KeyManager[] loadKeyStore(KeyManagerFactory kmf,
                                           KeyStore ks,
                                           InputStream is,
                                           String keyStoreLocation,
                                           String keyStorePassword,
                                           Logger log) {
    KeyManager[] keystoreManagers = null;
    try {
        ks.load(is, keyStorePassword.toCharArray());
        kmf.init(ks, keyStorePassword.toCharArray());
        keystoreManagers = kmf.getKeyManagers();
        LogUtils.log(log,
                     Level.FINE,
                     "LOADED_KEYSTORE",
                     keyStoreLocation);
    } catch (Exception e) {
        LogUtils.log(log,
                     Level.WARNING,
                     "FAILED_TO_LOAD_KEYSTORE",
                     new Object[]{keyStoreLocation, e.getMessage()});
    }
    return keystoreManagers;
}
 
Example #5
Source File: SSLUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static String getKeystore(String keyStoreLocation, Logger log) {
    final String logMsg;
    if (keyStoreLocation != null) {
        logMsg = "KEY_STORE_SET";
    } else {
        keyStoreLocation = SystemPropertyAction.getProperty("javax.net.ssl.keyStore");
        if (keyStoreLocation != null) {
            logMsg = "KEY_STORE_SYSTEM_PROPERTY_SET";
        } else {
            keyStoreLocation =
                SystemPropertyAction.getProperty("user.home") + "/.keystore";
            logMsg = "KEY_STORE_NOT_SET";
        }
    }
    LogUtils.log(log, Level.FINE, logMsg, keyStoreLocation);
    return keyStoreLocation;
}
 
Example #6
Source File: SSLUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static String getKeyPassword(String keyPassword, Logger log) {
    final String logMsg;
    if (keyPassword != null) {
        logMsg = "KEY_PASSWORD_SET";
    } else {
        keyPassword =
            SystemPropertyAction.getProperty("javax.net.ssl.keyPassword");
        if (keyPassword == null) {
            keyPassword =
                SystemPropertyAction.getProperty("javax.net.ssl.keyStorePassword");
        }
        logMsg = keyPassword != null
                 ? "KEY_PASSWORD_SYSTEM_PROPERTY_SET"
                 : "KEY_PASSWORD_NOT_SET";
    }
    LogUtils.log(log, Level.FINE, logMsg);
    return keyPassword;
}
 
Example #7
Source File: SSLUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static String getTrustStoreType(String trustStoreType, Logger log, String def) {
    final String logMsg;
    if (trustStoreType != null) {
        logMsg = "TRUST_STORE_TYPE_SET";
    } else {
        //Can default to JKS
        trustStoreType = SystemPropertyAction.getProperty("javax.net.ssl.trustStoreType");
        if (trustStoreType == null) {
            trustStoreType = def;
            logMsg = "TRUST_STORE_TYPE_NOT_SET";
        } else {
            logMsg = "TRUST_STORE_TYPE_SYSTEM_SET";
        }
    }
    LogUtils.log(log, Level.FINE, logMsg, trustStoreType);
    return trustStoreType;
}
 
Example #8
Source File: SpringBusFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected ConfigurableApplicationContext createApplicationContext(String[] cfgFiles, boolean includeDefaults) {
    try {
        return new BusApplicationContext(cfgFiles, includeDefaults, context, resolver);
    } catch (BeansException ex) {
        LogUtils.log(LOG, Level.WARNING, "INITIAL_APP_CONTEXT_CREATION_FAILED_MSG", ex, (Object[])null);
        ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
        if (contextLoader != BusApplicationContext.class.getClassLoader()) {
            Thread.currentThread().setContextClassLoader(
                BusApplicationContext.class.getClassLoader());
            try {
                return new BusApplicationContext(cfgFiles, includeDefaults, context);
            } finally {
                Thread.currentThread().setContextClassLoader(contextLoader);
            }
        }
        throw ex;
    }
}
 
Example #9
Source File: ClientImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void waitResponse(Exchange exchange) throws IOException {
    synchronized (exchange) {
        long remaining = synchronousTimeout;
        Long o = PropertyUtils.getLong(exchange.getOutMessage(), SYNC_TIMEOUT);
        if (o != null) {
            remaining = o;
        }
        while (!Boolean.TRUE.equals(exchange.get(FINISHED)) && remaining > 0) {
            long start = System.currentTimeMillis();
            try {
                exchange.wait(remaining);
            } catch (InterruptedException ex) {
                // ignore
            }
            long end = System.currentTimeMillis();
            remaining -= (int)(end - start);
        }
        if (!Boolean.TRUE.equals(exchange.get(FINISHED))) {
            LogUtils.log(LOG, Level.WARNING, "RESPONSE_TIMEOUT",
                exchange.getBindingOperationInfo().getOperationInfo().getName().toString());
            String msg = new org.apache.cxf.common.i18n.Message("RESPONSE_TIMEOUT", LOG, exchange
                .getBindingOperationInfo().getOperationInfo().getName().toString()).toString();
            throw new IOException(msg);
        }
    }
}
 
Example #10
Source File: SSLUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static String getKeystoreType(String keyStoreType, Logger log, String def) {
    final String logMsg;
    if (keyStoreType != null) {
        logMsg = "KEY_STORE_TYPE_SET";
    } else {
        keyStoreType = SystemPropertyAction.getProperty("javax.net.ssl.keyStoreType", null);
        if (keyStoreType == null) {
            keyStoreType = def;
            logMsg = "KEY_STORE_TYPE_NOT_SET";
        } else {
            logMsg = "KEY_STORE_TYPE_SYSTEM_SET";
        }
    }
    LogUtils.log(log, Level.FINE, logMsg, keyStoreType);
    return keyStoreType;
}
 
Example #11
Source File: LoggingOutInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testPrettyLoggingWithoutEncoding() throws Exception {
    control.replay();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintWriter pw = new PrintWriter(baos);
    
    LoggingOutInterceptor p = new LoggingOutInterceptor(pw);
    p.setPrettyLogging(true);
    CachedOutputStream cos = new CachedOutputStream();
    String s = "<today><is><the><twenty> <second> <of> <january> <two> <thousand> <and> <nine></nine> "
        + "</and></thousand></two></january></of></second></twenty></the></is></today>";
    cos.write(s.getBytes());
    Message message = new MessageImpl();
    message.setExchange(new ExchangeImpl());
    message.put(Message.CONTENT_TYPE, "application/xml");
    Logger logger = LogUtils.getL7dLogger(this.getClass());
    LoggingOutInterceptor.LoggingCallback l = p.new LoggingCallback(logger, message, cos);
    l.onClose(cos);
    String str = baos.toString();
    //format has changed
    assertFalse(str.matches(s));
    assertTrue(str.contains("<today>"));
}
 
Example #12
Source File: LoggingOutInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testPrettyLoggingWithEncoding() throws Exception {
    control.replay();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintWriter pw = new PrintWriter(baos);
    
    LoggingOutInterceptor p = new LoggingOutInterceptor(pw);
    p.setPrettyLogging(true);
    CachedOutputStream cos = new CachedOutputStream();
    String s = "<today><is><the><twenty> <second> <of> <january> <two> <thousand> <and> <nine></nine> "
        + "</and></thousand></two></january></of></second></twenty></the></is></today>";
    cos.write(s.getBytes());
    Message message = new MessageImpl();
    message.setExchange(new ExchangeImpl());
    message.put(Message.CONTENT_TYPE, "application/xml");
    message.put(Message.ENCODING, "UTF-8");
    Logger logger = LogUtils.getL7dLogger(this.getClass());
    LoggingOutInterceptor.LoggingCallback l = p.new LoggingCallback(logger, message, cos);
    l.onClose(cos);
    String str = baos.toString();
    //format has changed
    assertFalse(str.matches(s));
    assertTrue(str.contains("<today>"));

}
 
Example #13
Source File: LoggingOutInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testFormattingOverride() throws Exception {
    control.replay();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    // create a custom logging interceptor that overrides how formatting is done
    LoggingOutInterceptor p = new CustomFormatLoggingOutInterceptor(new PrintWriter(baos));
    CachedOutputStream cos = new CachedOutputStream();
    String s = "<today><is><the><twenty> <second> <of> <january> <two> <thousand> <and> <nine></nine> "
        + "</and></thousand></two></january></of></second></twenty></the></is></today>";
    cos.write(s.getBytes());

    Message message = new MessageImpl();
    message.setExchange(new ExchangeImpl());
    message.put(Message.CONTENT_TYPE, "application/xml");
    Logger logger = LogUtils.getL7dLogger(this.getClass());
    LoggingOutInterceptor.LoggingCallback l = p.new LoggingCallback(logger, message, cos);
    l.onClose(cos);

    String str = baos.toString();
    assertTrue(str.contains("<tomorrow/>"));

}
 
Example #14
Source File: SSLUtilsTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testDefaultCipherSuitesFilterExcluded() throws Exception {
    SSLContext sslContext = SSLContext.getInstance("TLS");
    sslContext.init(null, null, new java.security.SecureRandom());

    FiltersType filtersType = new FiltersType();
    filtersType.getInclude().add(".*_AES_.*");
    String[] supportedCipherSuites = sslContext.getSocketFactory().getSupportedCipherSuites();
    String[] filteredCipherSuites = SSLUtils.getFilteredCiphersuites(filtersType, supportedCipherSuites,
                                     LogUtils.getL7dLogger(SSLUtilsTest.class), false);

    assertTrue(filteredCipherSuites.length > 0);
    // Check we have no anon/EXPORT/NULL/etc ciphersuites
    assertFalse(Arrays.stream(
        filteredCipherSuites).anyMatch(c -> c.matches(".*NULL|anon|EXPORT|DES|MD5|CBC|RC4.*")));
}
 
Example #15
Source File: SSLUtilsTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testExclusionFilter() throws Exception {
    SSLContext sslContext = SSLContext.getInstance("TLS");
    sslContext.init(null, null, new java.security.SecureRandom());

    FiltersType filtersType = new FiltersType();
    filtersType.getInclude().add(".*_SHA384");
    filtersType.getExclude().add(".*_SHA256");
    String[] supportedCipherSuites = sslContext.getSocketFactory().getSupportedCipherSuites();
    String[] filteredCipherSuites = SSLUtils.getFilteredCiphersuites(filtersType, supportedCipherSuites,
                                     LogUtils.getL7dLogger(SSLUtilsTest.class), false);

    assertTrue(filteredCipherSuites.length > 0);
    // Check we have no SHA-256 ciphersuites
    assertFalse(Arrays.stream(
        filteredCipherSuites).anyMatch(c -> c.matches(".*_SHA256")));
}
 
Example #16
Source File: SSLUtilsTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testInclusionFilter() throws Exception {
    SSLContext sslContext = SSLContext.getInstance("TLS");
    sslContext.init(null, null, new java.security.SecureRandom());

    FiltersType filtersType = new FiltersType();
    filtersType.getInclude().add(".*_SHA256");
    String[] supportedCipherSuites = sslContext.getSocketFactory().getSupportedCipherSuites();
    String[] filteredCipherSuites = SSLUtils.getFilteredCiphersuites(filtersType, supportedCipherSuites,
                                     LogUtils.getL7dLogger(SSLUtilsTest.class), false);

    assertTrue(filteredCipherSuites.length > 0);
    // Check we have SHA-256 ciphersuites
    assertTrue(Arrays.stream(
        filteredCipherSuites).anyMatch(c -> c.matches(".*_SHA256")));
}
 
Example #17
Source File: CxfRsHttpListener.java    From tomee with Apache License 2.0 6 votes vote down vote up
private void addMandatoryProviders(final Collection<Object> instances, final ServiceConfiguration serviceConfiguration) {
    if (SystemInstance.get().getProperty("openejb.jaxrs.jsonProviders") == null) {
        if (!shouldSkipProvider(WadlDocumentMessageBodyWriter.class.getName())) {
            instances.add(new WadlDocumentMessageBodyWriter());
        }
    }
    if (!shouldSkipProvider(EJBExceptionMapper.class.getName())) {
        instances.add(new EJBExceptionMapper());
    }
    if (!shouldSkipProvider(ValidationExceptionMapper.class.getName())) {
        instances.add(new ValidationExceptionMapper());
        final String level = SystemInstance.get()
                .getProperty(
                    "openejb.cxf.rs.bval.log.level",
                    serviceConfiguration.getProperties().getProperty(CXF_JAXRS_PREFIX + "bval.log.level"));
        if (level != null) {
            try {
                LogUtils.getL7dLogger(ValidationExceptionMapper.class).setLevel(Level.parse(level));
            } catch (final UnsupportedOperationException uoe) {
                LOGGER.warning("Can't set level " + level + " on " +
                        "org.apache.cxf.jaxrs.validation.ValidationExceptionMapper logger, " +
                        "please configure it in your logging framework.");
            }
        }
    }
}
 
Example #18
Source File: SSLSocketFactoryWrapper.java    From cxf with Apache License 2.0 6 votes vote down vote up
private Socket enableCipherSuites(Socket s, Object[] logParams) {
    SSLSocket socket = (SSLSocket)s;

    if (socket == null) {
        LogUtils.log(LOG, Level.SEVERE,
                     "PROBLEM_CREATING_OUTBOUND_REQUEST_SOCKET",
                     logParams);
        return socket;
    }

    if (protocol != null) {
        String[] p = findProtocols(protocol, socket.getSupportedProtocols());
        if (p != null) {
            socket.setEnabledProtocols(p);
        }
    }
    if (ciphers != null) {
        socket.setEnabledCipherSuites(ciphers);
    }

    return socket;
}
 
Example #19
Source File: ConfigurationImplTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testInvalidConstraintOnProvider() {
    TestHandler handler = new TestHandler();
    LogUtils.getL7dLogger(ConfigurableImpl.class).addHandler(handler);

    try (ConfigurableImpl<Client> configurable 
            = new ConfigurableImpl<>(createClientProxy(), RuntimeType.CLIENT)) {
        Configuration config = configurable.getConfiguration();

        configurable.register(ClientFilterConstrainedToServer.class);

        assertEquals(0, config.getInstances().size());

        for (String message : handler.messages) {
            if (message.startsWith("WARN") && message.contains("cannot be registered in ")) {
                return; // success
            }
        }
    }
    fail("did not log expected message");
}
 
Example #20
Source File: ConfigurationImplTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testChecksConstrainedToAnnotationDuringRegistration() {
    TestHandler handler = new TestHandler();
    LogUtils.getL7dLogger(ConfigurableImpl.class).addHandler(handler);

    try (ConfigurableImpl<Client> configurable 
            = new ConfigurableImpl<>(createClientProxy(), RuntimeType.CLIENT)) {
        Configuration config = configurable.getConfiguration();

        configurable.register(ContainerResponseFilterImpl.class);

        assertEquals(0, config.getInstances().size());

        for (String message : handler.messages) {
            if (message.startsWith("WARN") && message.contains("Null, empty or invalid contracts specified")) {
                return; // success
            }
        }
    }
    fail("did not log expected message");
}
 
Example #21
Source File: JaxbAssertionBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected T getData(Element element) {
    Object obj = null;
    Unmarshaller um = getUnmarshaller();
    try {
        obj = um.unmarshal(element);
    } catch (JAXBException ex) {
        LogUtils.log(LOG, Level.SEVERE, "UNMARSHAL_ELEMENT_EXC", ex);
    } finally {
        JAXBUtils.closeUnmarshaller(um);
    }
    if (obj instanceof JAXBElement<?>) {
        JAXBElement<?> el = (JAXBElement<?>)obj;
        obj = el.getValue();
    }
    if (null != obj && LOG.isLoggable(Level.FINE)) {
        LOG.fine("Unmarshaled element into object of type: " + obj.getClass().getName()
             + "    value: " + obj);
    }
    return (T)obj;
}
 
Example #22
Source File: ConfigurationImplTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testInvalidContract() {
    TestHandler handler = new TestHandler();
    LogUtils.getL7dLogger(ConfigurationImpl.class).addHandler(handler);

    ConfigurationImpl c = new ConfigurationImpl(RuntimeType.SERVER);
    ContainerResponseFilter filter = new ContainerResponseFilterImpl();
    assertFalse(c.register(filter,
                           Collections.<Class<?>, Integer>singletonMap(MessageBodyReader.class, 1000)));

    for (String message : handler.messages) {
        if (message.startsWith("WARN") && message.contains("does not implement specified contract")) {
            return; // success
        }
    }
    fail("did not log expected message");
}
 
Example #23
Source File: SoapFaultFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
Fault createSoap12Fault(SequenceFault sf, Message msg) {
    SoapFault fault = (SoapFault)createSoap11Fault(sf);
    fault.setSubCode(sf.getFaultCode());
    Object detail = sf.getDetail();
    if (null == detail) {
        return fault;
    }

    try {
        RMProperties rmps = RMContextUtils.retrieveRMProperties(msg, false);
        AddressingProperties maps = RMContextUtils.retrieveMAPs(msg, false, false);
        EncoderDecoder codec = ProtocolVariation.findVariant(rmps.getNamespaceURI(),
            maps.getNamespaceURI()).getCodec();
        setDetail(fault, detail, codec);
    } catch (Exception ex) {
        LogUtils.log(LOG, Level.SEVERE, "MARSHAL_FAULT_DETAIL_EXC", ex);
        ex.printStackTrace();
    }
    return fault;
}
 
Example #24
Source File: ClientImplTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testRegisterNullComponentObject() {
    // Per register's javadoc, "Implementations MUST ignore attempts to register a component class for an empty
    // or null collection of contracts via this method and SHOULD raise a warning about such event."
    TestHandler handler = new TestHandler();
    LogUtils.getL7dLogger(ConfigurableImpl.class).addHandler(handler);

    ClientBuilder.newClient().register(new MyInterceptor(), (Class<?>[]) null);

    for (String message : handler.messages) {
        if (message.startsWith("WARN") && message.contains("Null, empty or invalid contracts specified")) {
            return; // success
        }
    }
    fail("did not log expected message");
}
 
Example #25
Source File: LoggerHelperTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testEnableDisableConsoleLogging() {
    Logger rootLogger = LogUtils.getLogger(this.getClass(), null, "");
    Handler handler;

    /*Handler handler = LoggerHelper.getHandler(rootLogger, LoggerHelper.CONSOLE_HANDLER);
    assertNotNull("default console appender is there", handler);*/

    LoggerHelper.enableConsoleLogging();

    handler = LoggerHelper.getHandler(rootLogger, LoggerHelper.CONSOLE_HANDLER);
    assertNotNull("default console appender is not there", handler);

    LoggerHelper.disableConsoleLogging();

    handler = LoggerHelper.getHandler(rootLogger, LoggerHelper.CONSOLE_HANDLER);
    assertNull("Unexpected appender after disable", handler);
}
 
Example #26
Source File: ClientImplTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testRegisterNullComponentClass() {
    // Per register's javadoc, "Implementations MUST ignore attempts to register a component class for an empty
    // or null collection of contracts via this method and SHOULD raise a warning about such event."
    TestHandler handler = new TestHandler();
    LogUtils.getL7dLogger(ConfigurableImpl.class).addHandler(handler);

    ClientBuilder.newClient().register(MyInterceptor.class, (Class<?>[]) null);

    for (String message : handler.messages) {
        if (message.startsWith("WARN") && message.contains("Null, empty or invalid contracts specified")) {
            return; // success
        }
    }
    fail("did not log expected message");
}
 
Example #27
Source File: ConfigurerImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void initWildcardDefinitionMap() {
    if (null != appContexts) {
        for (ApplicationContext appContext : appContexts) {
            for (String n : appContext.getBeanDefinitionNames()) {
                if (isWildcardBeanName(n)) {
                    AutowireCapableBeanFactory bf = appContext.getAutowireCapableBeanFactory();
                    BeanDefinitionRegistry bdr = (BeanDefinitionRegistry) bf;
                    BeanDefinition bd = bdr.getBeanDefinition(n);
                    String className = bd.getBeanClassName();
                    if (null != className) {
                        final String name = n.charAt(0) != '*' ? n
                                : "." + n.replaceAll("\\.", "\\."); //old wildcard
                        try {
                            Matcher matcher = Pattern.compile(name).matcher("");
                            List<MatcherHolder> m = wildCardBeanDefinitions.get(className);
                            if (m == null) {
                                m = new ArrayList<>();
                                wildCardBeanDefinitions.put(className, m);
                            }
                            MatcherHolder holder = new MatcherHolder(n, matcher);
                            m.add(holder);
                        } catch (PatternSyntaxException npe) {
                            //not a valid patter, we'll ignore
                        }
                    } else {
                        LogUtils.log(LOG, Level.WARNING, "WILDCARD_BEAN_ID_WITH_NO_CLASS_MSG", n);
                    }
                }
            }
        }
    }
}
 
Example #28
Source File: RMTxStore.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void abort(Connection con) {
    try {
        con.rollback();
    } catch (SQLException ex) {
        LogUtils.log(LOG, Level.SEVERE, "ABORT_FAILED_MSG", ex);
    }
}
 
Example #29
Source File: SpringBusFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Bus createBus(URL[] urls, boolean includeDefaults) {
    try {
        return finishCreatingBus(createAppContext(urls, includeDefaults));
    } catch (BeansException ex) {
        LogUtils.log(LOG, Level.WARNING, "APP_CONTEXT_CREATION_FAILED_MSG", ex, (Object[])null);
        throw new RuntimeException(ex);
    }
}
 
Example #30
Source File: RMTxStore.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Connection verifyConnection() {
    Connection con;
    if (connection == null) {
        // return a new connection
        con = createConnection();
    } else {
        // return the cached connection or create and cache a new one if the old one is dead
        synchronized (this) {
            if (createdConnection && nextReconnectAttempt > 0
                && (maxReconnectAttempts < 0 || maxReconnectAttempts > reconnectAttempts)) {
                if (System.currentTimeMillis() > nextReconnectAttempt) {
                    // destroy the broken connection
                    destroy();
                    // try to reconnect
                    reconnectAttempts++;
                    init();
                    // reset the next reconnect attempt time
                    nextReconnectAttempt = 0;
                } else {
                    LogUtils.log(LOG, Level.INFO, "WAIT_RECONNECT_MSG");
                }
            }
        }
        con = connection;
    }

    return con;
}