Java Code Examples for org.apache.axis2.AxisFault#makeFault()

The following examples show how to use org.apache.axis2.AxisFault#makeFault() . 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: IheHTTPServer.java    From openxds with Apache License 2.0 6 votes vote down vote up
/**
     * init method in TransportListener
     *
     * @param axisConf
     * @param transprtIn
     * @throws AxisFault
     */
    public void init(ConfigurationContext axisConf, TransportInDescription transprtIn)
            throws AxisFault {
        try {
            this.configurationContext = axisConf;

//            if (httpFactory == null) {
//                httpFactory = new IheHttpFactory(configurationContext, actor.getConnection());
//            }
//
//            if (actor.getConnection().getHostname() != null) {
//                hostAddress = actor.getConnection().getHostname();
//            } else {
//                hostAddress = httpFactory.getHostAddress();
//            }
        } catch (Exception e1) {
            throw AxisFault.makeFault(e1);
        }
    }
 
Example 2
Source File: Java2WSDL.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
/**
 * This is the fall though method for wsdlview. This will check for required resources.
 *
 * @param options options array
 * @param uuids   uuid array
 * @return String id
 * @throws AxisFault will be thrown.
 */
public String java2wsdlWithResources(String[] options, String[] uuids) throws AxisFault {

    ClassLoader prevCl = Thread.currentThread().getContextClassLoader();
    try {
        URL[] urls = new URL[uuids.length];
        for (int i = 0; i < uuids.length; i++) {
            urls[i] = new File(uuids[i]).toURL();
        }
        ClassLoader newCl = URLClassLoader.newInstance(urls, prevCl);
        Thread.currentThread().setContextClassLoader(newCl);
        return java2wsdl(options);
    } catch (MalformedURLException e) {
        throw AxisFault.makeFault(e);
    } finally {
        Thread.currentThread().setContextClassLoader(prevCl);
    }

}
 
Example 3
Source File: IheHttpFactory.java    From openxds with Apache License 2.0 5 votes vote down vote up
private TimeUnit getTimeUnitParam(String name, TimeUnit def) throws AxisFault {
    String config = getStringParam(name, null);
    if (config != null) {
        try {
            return (TimeUnit) TimeUnit.class.getField(config).get(null);
        } catch (Exception e) {
            throw AxisFault.makeFault(e);
        }
    }
    return def;
}
 
Example 4
Source File: IheHTTPServer.java    From openxds with Apache License 2.0 5 votes vote down vote up
/**
 * Start this server as a NON-daemon.
 */
public void start() throws AxisFault {
    try {
        embedded = new SimpleHttpServer(httpFactory, actor.getConnection());
        embedded.init();
        embedded.start();
    } catch (IOException e) {
        log.error(e.getMessage(), e);
        throw AxisFault.makeFault(e);
    }
}
 
Example 5
Source File: SystemStatistics.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public SystemStatistics(AxisConfiguration configuration) throws AxisFault {
    try {
        dateFormatter = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss");
        statService = new SystemStatisticsUtil();
        javaVersion = System.getProperty("java.version");
        update(configuration);
    } catch (Exception e) {
        throw AxisFault.makeFault(e);
    }
}
 
Example 6
Source File: SystemStatistics.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public SystemStatistics(MessageContext messageContext) throws AxisFault {
    try {
        statService = new SystemStatisticsUtil();
        javaVersion = System.getProperty("java.version");
        update(messageContext);
    } catch (Exception e) {
        throw AxisFault.makeFault(e);
    }
}
 
Example 7
Source File: SystemStatistics.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public void update(MessageContext messageContext) throws AxisFault {
    try {

        currentInvocationResponseTime = statService.getCurrentSystemResponseTime(messageContext);
        currentInvocationResponseCount = statService.getCurrentSystemResponseCount(messageContext);
        currentInvocationRequestCount = statService.getCurrentSystemRequestCount(messageContext);
        currentInvocationFaultCount = statService.getCurrentSystemFaultCount(messageContext);

    } catch (Exception e) {
        throw AxisFault.makeFault(e);
    }
}
 
Example 8
Source File: SimpleMessageReceiver.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public void start()throws AxisFault {
    try {
        //Register the callback service
        AxisService messageCollectorService = new AxisService("MessageCollector");
        MessageReceiver messageReceiver = new MessageReceiver() {
            public void receive(MessageContext messageCtx) throws AxisFault {
                if(callback != null){
                    callback.mesageReceived(messageCtx.getEnvelope());
                }else{
                    System.out.println("Received " + messageCtx.getEnvelope());    
                }
            }
        };
        InOutAxisOperation operation1 = new InOutAxisOperation(new QName("receive"));
        operation1.setMessageReceiver(messageReceiver);
        messageCollectorService.addOperation(operation1);
        
        configContext.getAxisConfiguration().addService(messageCollectorService);
        
        axis2Server = new SimpleHTTPServer(configContext, 7777);
        axis2Server.start();
        
        eventSinkUrl = axis2Server.getEPRForService(messageCollectorService.getName(), InetAddress.getLocalHost().getHostName());
    } catch (UnknownHostException e) {
        throw AxisFault.makeFault(e);
    }
}
 
Example 9
Source File: AbstractXDSRawXMLInMessageReceiver.java    From openxds with Apache License 2.0 4 votes vote down vote up
private Method findOperation(AxisOperation op, Class implClass) throws AxisFault {

		Method method = (Method) (op.getParameterValue("myMethod"));

		if (method != null)
			return method;

		String methodName = op.getName().getLocalPart();

		try {

			// Looking for a method of the form "void method(OMElement)"

			
			method = implClass.getMethod(methodName,
					new Class[] { OMElement.class });

//			if (1 == 1) 
//				throw new Exception("return type is " + method.getReturnType().getName() + "\n" +
//						"methodName is " + methodName + "\n" +
//						"class is " + implClass.getName());
			
			if (method.getReturnType().getName().equals("void")) {
				try {
					op.addParameter("myMethod", method);
				} catch (AxisFault axisFault) {
					throw AxisFault.makeFault(axisFault);
				}
				return method;
			}

		} catch (Exception e) {
			throw AxisFault.makeFault(e);
		}
		
		if (logger.isDebugEnabled()) {
			logger.debug("return class is " + method.getReturnType().getName());
		}
		
		return null;

	}
 
Example 10
Source File: SystemStatistics.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
public void update(AxisConfiguration axisConfig) throws AxisFault {

        int tenantId =  PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
        Parameter systemStartTime =
                axisConfig.getParameter(CarbonConstants.SERVER_START_TIME);
        long startTime = 0;
        if (systemStartTime != null) {
            startTime = Long.parseLong((String) systemStartTime.getValue());
        }
        Date stTime = new Date(startTime);

        // only super admin can view serverStartTime and systemUpTime
        if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
            serverStartTime = dateFormatter.format(stTime);
            systemUpTime = (getTime((System.currentTimeMillis() - startTime) / 1000));
        }
        try {
            totalRequestCount = statService.getTotalSystemRequestCount(axisConfig);
            totalResponseCount = statService.getSystemResponseCount(axisConfig);
            totalFaultCount = statService.getSystemFaultCount(axisConfig);
            avgResponseTime = statService.getAvgSystemResponseTime(axisConfig);
            maxResponseTime = statService.getMaxSystemResponseTime(axisConfig);
            minResponseTime = statService.getMinSystemResponseTime(axisConfig);

        } catch (Exception e) {
            throw AxisFault.makeFault(e);
        }

        Runtime runtime = Runtime.getRuntime();

        // only super admin can view usedMemory and totalMemory
        if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
            usedMemory = formatMemoryValue(runtime.totalMemory() - runtime.freeMemory());
            totalMemory = formatMemoryValue(runtime.totalMemory());
        }
        wso2wsasVersion = ServerConfiguration.getInstance().getFirstProperty("Version");

        int activeServices = 0;
        for (Iterator services = axisConfig.getServices().values().iterator();
             services.hasNext(); ) {
            AxisService axisService = (AxisService) services.next();
            AxisServiceGroup asGroup = (AxisServiceGroup) axisService.getParent();
            if (axisService.isActive() &&
                !axisService.isClientSide() &&
                !SystemFilter.isFilteredOutService(asGroup)) {
                activeServices++;
            }
        }

        this.services = activeServices;
        try {
            // only susper admin is allow to view serverName.
            if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
                serverName = NetworkUtils.getLocalHostname();
            }
        } catch (SocketException ignored) {
        }
    }