Search in sources :

Example 1 with ServiceType

use of org.apache.knox.gateway.services.ServiceType in project knox by apache.

the class DeploymentFactory method injectServices.

private static void injectServices(Object contributor) {
    if (gatewayServices != null) {
        Statement stmt;
        for (ServiceType serviceType : gatewayServices.getServiceTypes()) {
            try {
                // TODO: this is just a temporary injection solution
                // TODO: test for the existence of the setter before attempting it
                // TODO: avoid exception throwing when there is no setter
                stmt = new Statement(contributor, "set" + serviceType.getServiceTypeName(), new Object[] { gatewayServices.getService(serviceType) });
                stmt.execute();
            } catch (NoSuchMethodException e) {
            // TODO: eliminate the possibility of this being thrown up front
            } catch (Exception e) {
                // Maybe it makes sense to throw exception
                log.failedToInjectService(serviceType.getServiceTypeName(), e);
                throw new DeploymentException("Failed to inject service.", e);
            }
        }
    }
}
Also used : Statement(java.beans.Statement) ServiceType(org.apache.knox.gateway.services.ServiceType) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException)

Aggregations

Statement (java.beans.Statement)1 IOException (java.io.IOException)1 JAXBException (javax.xml.bind.JAXBException)1 ServiceType (org.apache.knox.gateway.services.ServiceType)1