org.apache.axis2.description.AxisServiceGroup Java Examples

The following examples show how to use org.apache.axis2.description.AxisServiceGroup. 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: UtilServer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public static ServiceContext createAdressedEnabledClientSide(
        AxisService service) throws AxisFault {
    File file = getAddressingMARFile();
    TestCase.assertTrue(file.exists());
    ConfigurationContext configContext = ConfigurationContextFactory
            .createConfigurationContextFromFileSystem(
                    "target/test-resources/integrationRepo", null);
    AxisModule axisModule = DeploymentEngine.buildModule(file,
                                                         configContext.getAxisConfiguration());

    AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
    axisConfiguration.addModule(axisModule);
    axisConfiguration.addService(service);
    ServiceGroupContext serviceGroupContext =
            configContext.createServiceGroupContext((AxisServiceGroup) service.getParent());
    return serviceGroupContext.getServiceContext(service);
}
 
Example #2
Source File: UtilServer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public static ServiceContext createAdressedEnabledClientSide(
        AxisService service, String clientHome) throws AxisFault {
    File file = getAddressingMARFile();
    TestCase.assertTrue(file.exists());

    ConfigurationContext configContext = ConfigurationContextFactory
            .createConfigurationContextFromFileSystem(clientHome, null);
    AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();

    AxisModule axisModule = DeploymentEngine.buildModule(file,axisConfiguration);
    axisConfiguration.addModule(axisModule);

    axisConfiguration.addService(service);
    ServiceGroupContext serviceGroupContext =
            configContext.createServiceGroupContext((AxisServiceGroup) service.getParent());
    return serviceGroupContext.getServiceContext(service);
}
 
Example #3
Source File: SampleAxis2Server.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public void deployService(Object service) throws IOException {
    String artifactName = service + ".aar";
    File file = copyResourceToFileSystem(artifactName, artifactName);
    AxisServiceGroup serviceGroup = DeploymentEngine.loadServiceGroup(file, cfgCtx);
    cfgCtx.getAxisConfiguration().addServiceGroup(serviceGroup);

}
 
Example #4
Source File: DBUtils.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This method verifies whether there's an existing data service group for the given name data service group.
 *
 * @param axisConfiguration Axis configuration
 * @param dataServiceGroup  Data service Group
 * @return Boolean (Is available)
 * @throws AxisFault
 */
public static boolean isAvailableDSServiceGroup(AxisConfiguration axisConfiguration, String dataServiceGroup)
        throws AxisFault {
    Iterator<AxisServiceGroup> map = axisConfiguration.getServiceGroups();
    while (map.hasNext()) {
        AxisServiceGroup serviceGroup = map.next();
        if (serviceGroup.getServiceGroupName().equals(dataServiceGroup)) {
            return true;
        }
    }
    return false;
}
 
Example #5
Source File: DBUtils.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This method returns an active existing Axis Service for the given name data service group.
 *
 * @param axisConfiguration Axis configuration
 * @param serviceName       Data service Name
 * @return Boolean (Is available)
 * @throws AxisFault
 */
public static AxisService getActiveAxisServiceAccordingToDataServiceGroup(AxisConfiguration axisConfiguration,
                                                                          String serviceName) throws AxisFault {
    Iterator<AxisServiceGroup> map = axisConfiguration.getServiceGroups();
    AxisServiceGroup serviceGroup = null;
    while (map.hasNext()) {
        serviceGroup = map.next();
        if ( serviceGroup.getServiceGroupName().equals(serviceName)) {
            break;
        } else {
            serviceGroup = null;
        }
    }

    if (serviceName.contains("/")) {
        String[] splitArray = serviceName.split("\\/");
        if (splitArray.length >= 1) {
            serviceName = splitArray[splitArray.length - 1];
        }
    }

    if (serviceGroup != null) {
        AxisService service = serviceGroup.getService(serviceName);
        if (service != null && service.isActive()) {
            return service;
        }
    }
    return null;
}
 
Example #6
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates AxisService with the given deployment information.
 */
private AxisService processService(DeploymentFileData currentFile,
		AxisServiceGroup axisServiceGroup, ConfigurationContext configCtx)
		throws DataServiceFault {
	/*
		Security Comment
		CurrentFile contains the actual dbs data location in the server. there isn't any input from the user.
	 */
	AxisService axisService = createDBService(currentFile.getAbsolutePath(), configCtx.getAxisConfiguration());
	axisService.setParent(axisServiceGroup);
	axisService.setClassLoader(axisConfig.getServiceClassLoader());
       /* handle services.xml, if exists */
	this.handleTransports(currentFile, axisService);
	return axisService;
}
 
Example #7
Source File: SampleAxis2Server.java    From product-ei with Apache License 2.0 5 votes vote down vote up
public void deployService(Object service) throws IOException {
    String artifactName = service + ".aar";
    File file = copyResourceToFileSystem(artifactName, artifactName);
    AxisServiceGroup serviceGroup = DeploymentEngine.loadServiceGroup(file, cfgCtx);
    cfgCtx.getAxisConfiguration().addServiceGroup(serviceGroup);

}
 
Example #8
Source File: Axis2ServerManager.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public void deployService(Object service) throws IOException {
    String artifactName = service + ".aar";
    File file = copyResourceToFileSystem(artifactName, artifactName);
    AxisServiceGroup serviceGroup = DeploymentEngine.loadServiceGroup(file, cfgCtx);
    cfgCtx.getAxisConfiguration().addServiceGroup(serviceGroup);
}
 
Example #9
Source File: ProxyTimerTask.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
public void run() {

        synchronized (axisConfig) {
            PrivilegedCarbonContext.startTenantFlow();
            try {
                PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
                privilegedCarbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
                privilegedCarbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);

                AxisServiceGroup proxyAxisServiceGroup =
                        axisConfig.getServiceGroup(WSDL2FormGenerator.TRYIT_SG_NAME);
                if (proxyAxisServiceGroup != null) {
                    List removeServiceList = new ArrayList();
                    for (Iterator iterator = proxyAxisServiceGroup.getServices();
                         iterator.hasNext();) {
                        AxisService axisServce = (AxisService) iterator.next();
                        Long longTime =
                                (Long) axisServce
                                        .getParameterValue(WSDL2FormGenerator.LAST_TOUCH_TIME);
                        if ((System.currentTimeMillis() - longTime.longValue()) > WSDL2FormGenerator
                                .PERIOD) {
                            removeServiceList.add(axisServce.getName());
                        }

                    }
                    if (removeServiceList.size() > 0) {
                        for (Iterator iterator = removeServiceList.iterator(); iterator.hasNext();)
                        {
                            String axisServiceName = (String) iterator.next();
                            proxyAxisServiceGroup.removeService(axisServiceName);
                        }
                    }
                    boolean isLast = proxyAxisServiceGroup.getServices().hasNext();
                    if (!isLast) {
                        axisConfig.removeServiceGroup(WSDL2FormGenerator.TRYIT_SG_NAME);
                    }
                }
            } catch (AxisFault axisFault) {
                String msg = "Fault occured when manipulating Tryit proxy service group";
                log.error(msg, axisFault);
            } finally {
                PrivilegedCarbonContext.endTenantFlow();
            }

        }
    }
 
Example #10
Source File: ApplicationAdmin.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
/**
 * Finds the AxisServiceGroup which corresponds to the given cApp Artifact. Artifact file
 * name is used to identify the AxisServiceGroup. Then the service type is also checked with
 * the type of the given artifact.
 *
 * @param artifact - cApp artifact
 * @return - corresponding AxisServiceGroup
 */
private AxisServiceGroup findServiceGroupForArtifact(Artifact artifact) {
    // Number of files in a service artifact should be 1
    if (artifact.getFiles().size() != 1) {
        return null;
    }

    String fileName = artifact.getFiles().get(0).getName();
    AxisConfiguration axisConfiguration = getAxisConfig();
    Iterator<AxisServiceGroup> serviceGroups = axisConfiguration.getServiceGroups();

    while (serviceGroups.hasNext()) {
        AxisServiceGroup sg = serviceGroups.next();

        // Filtering the admin services
        if (SystemFilter.isFilteredOutService(sg)) {
            continue;  // No advancement of currentIndex
        }

        AxisService axisService = null;
        Iterator<AxisService> services = sg.getServices();

        // Find a service with the file name in this service group
        while (services.hasNext()) {
            AxisService temp = services.next();
            if (temp.getFileName() != null) {
                axisService = temp;
                break;
            }
        }
        if (axisService != null) {
            String filePath = axisService.getFileName().getPath().trim();
            if (filePath.endsWith(fileName)) {
                String serviceType = getArtifactTypeFromService(axisService, fileName);
                if (serviceType.equals(artifact.getType())) {
                    return sg;
                }
            }
        }
    }
    return null;
}
 
Example #11
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) {
        }
    }
 
Example #12
Source File: SystemStatisticsDeploymentInterceptor.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
public void serviceGroupUpdate(AxisEvent axisEvent, AxisServiceGroup axisServiceGroup) {
    // Nothing to implement
}
 
Example #13
Source File: IdentityMgtDeploymentInterceptor.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void serviceGroupUpdate(AxisEvent axisEvent, AxisServiceGroup axisServiceGroup) {
    //Overridden method from parent interface, don't need any code here.
}
 
Example #14
Source File: SecurityDeploymentInterceptor.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void serviceGroupUpdate(AxisEvent event, AxisServiceGroup serviceGroup) {
    // This method will not be used
}
 
Example #15
Source File: STSDeploymentInterceptor.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void serviceGroupUpdate(AxisEvent event, AxisServiceGroup group) {
    // Nothing to implement
}
 
Example #16
Source File: TenantSTSObserver.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void serviceGroupUpdate(AxisEvent axisEvent, AxisServiceGroup axisServiceGroup) {
    // Nothing to implement
}
 
Example #17
Source File: STSObserver.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
@Override
public void serviceGroupUpdate(AxisEvent arg0, AxisServiceGroup arg1) {
    // Nothing to implement

}
 
Example #18
Source File: Axis2ServerManager.java    From product-ei with Apache License 2.0 4 votes vote down vote up
public void deployService(Object service) throws IOException {
    String artifactName = service + ".aar";
    File file = copyResourceToFileSystem(artifactName, artifactName);
    AxisServiceGroup serviceGroup = DeploymentEngine.loadServiceGroup(file, cfgCtx);
    cfgCtx.getAxisConfiguration().addServiceGroup(serviceGroup);
}
 
Example #19
Source File: IdentityMgtDeploymentInterceptor.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
@Override
public void serviceGroupUpdate(AxisEvent axisEvent, AxisServiceGroup axisServiceGroup) {
    //Overridden method from parent interface, don't need any code here.
}
 
Example #20
Source File: ServiceBusInitializer.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
private ServerContextInformation initESB(String name) throws AxisFault {

        if (configCtxSvc != null) {
            ConfigurationContext configContext = configCtxSvc.getServerConfigContext();
            log.debug("Initializing Apache Synapse...");
            configurationInformation = ServerConfigurationInformationFactory.createServerConfigurationInformation
                    (configContext.getAxisConfiguration());
            // ability to specify the SynapseServerName as a system property
            if (System.getProperty("SynapseServerName") != null) {
                configurationInformation.setServerName(System.getProperty("SynapseServerName"));
            }
            // for now we override the default configuration location with the value in registry
            String synapseConfigsLocation = configurationInformation.getSynapseXMLLocation();
            if (synapseConfigsLocation != null) {
                configurationInformation.setSynapseXMLLocation(synapseConfigsLocation + File.separator + name);
            } else {
                configurationInformation.setSynapseXMLLocation(ServiceBusConstants.DEFAULT_SYNAPSE_CONFIGS_LOCATION +
                        name);
            }
            configurationInformation.setCreateNewInstance(false);
            configurationInformation.setServerControllerProvider(CarbonSynapseController.class.getName());
            if (isRunningSamplesMode()) {
                if (System.getProperty(ServiceBusConstants.ESB_SAMPLE_SYSTEM_PROPERTY) != null) {
                    configurationInformation.setSynapseXMLLocation("repository" + File.separator + "samples" + File
                            .separator + "synapse_sample_" + System.getProperty(ServiceBusConstants
                            .ESB_SAMPLE_SYSTEM_PROPERTY) + ".xml");
                } else {
                    configurationInformation.setSynapseXMLLocation("samples" + File.separator + "service-bus" + File
                            .separator + "synapse_sample_" + System.getProperty(ServiceBusConstants
                            .EI_SAMPLE_SYSTEM_PROPERTY) + ".xml");
                }
            }
            serverManager = new ServerManager();
            ServerContextInformation contextInfo = new ServerContextInformation(configContext,
                    configurationInformation);

            if (secretCallbackHandlerService != null) {
                contextInfo.addProperty(SecurityConstants.PROP_SECRET_CALLBACK_HANDLER, secretCallbackHandlerService
                        .getSecretCallbackHandler());
            }
            AxisConfiguration axisConf = configContext.getAxisConfiguration();
            axisConf.addParameter(new Parameter(ServiceBusConstants.SYNAPSE_CURRENT_CONFIGURATION, name));
            if (isRunningDebugMode()) {
                log.debug("Micro Integrator started in Debug mode for super tenant");
                createSynapseDebugEnvironment(contextInfo);
            }
            boolean initConnectors = !Boolean.valueOf(System.getProperty(ServiceBusConstants
                    .DISABLE_CONNECTOR_INIT_SYSTEM_PROPERTY));
            if (initConnectors) {
                // Enable connectors
                SynapseArtifactInitUtils.initializeConnectors(axisConf);
            }
            serverManager.init(configurationInformation, contextInfo);
            serverManager.start();
            AxisServiceGroup serviceGroup = axisConf.getServiceGroup(SynapseConstants.SYNAPSE_SERVICE_NAME);
            serviceGroup.addParameter("hiddenService", "true");
            return contextInfo;
        } else {
            handleFatal("Couldn't initialize Synapse, " + "ConfigurationContext service or SynapseRegistryService is " +
                    "not available");
        }
        // never executes, but keeps the compiler happy
        return null;
    }
 
Example #21
Source File: ServiceAdmin.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public ServiceMetaData getServiceData(String serviceName) throws Exception {

        AxisService service = axisConfiguration.getServiceForActivation(serviceName);

        if (service == null) {
            String msg = "Invalid service name, service not found : " + serviceName;
            throw new AxisFault(msg);
        }

        String serviceType = getServiceType(service);
        List<String> ops = new ArrayList<String>();
        for (Iterator<AxisOperation> opIter = service.getOperations(); opIter.hasNext(); ) {
            AxisOperation axisOperation = opIter.next();

            if (axisOperation.getName() != null) {
                ops.add(axisOperation.getName().getLocalPart());
            }
        }

        ServiceMetaData serviceMetaData = new ServiceMetaData();
        serviceMetaData.setOperations(ops.toArray(new String[ops.size()]));
        serviceMetaData.setName(serviceName);
        serviceMetaData.setServiceId(serviceName);
        serviceMetaData.setServiceVersion("");
        serviceMetaData.setActive(service.isActive());
        String[] eprs = this.getServiceEPRs(serviceName);
        serviceMetaData.setEprs(eprs);
        serviceMetaData.setServiceType(serviceType);

        serviceMetaData.setWsdlURLs(Utils.getWsdlInformation(serviceName, axisConfiguration));

        AxisServiceGroup serviceGroup = (AxisServiceGroup) service.getParent();
        serviceMetaData.setFoundWebResources(serviceGroup.isFoundWebResources());
        serviceMetaData.setScope(service.getScope());
        serviceMetaData.setWsdlPorts(service.getEndpoints());
        Parameter deploymentTime = service.getParameter("serviceDeploymentTime");
        if (deploymentTime != null) {
            serviceMetaData.setServiceDeployedTime((Long) deploymentTime.getValue());
        }

        serviceMetaData.setServiceGroupName(serviceGroup.getServiceGroupName());

        if (service.getDocumentation() != null) {
            serviceMetaData.setDescription(service.getDocumentation());
        } else {
            serviceMetaData.setDescription("No service description found");
        }

        Parameter parameter = service.getParameter("enableMTOM");
        if (parameter != null) {
            serviceMetaData.setMtomStatus((String) parameter.getValue());
        } else {
            serviceMetaData.setMtomStatus("false");
        }

        parameter = service.getParameter("disableTryIt");
        if (parameter != null && Boolean.TRUE.toString().equalsIgnoreCase((String) parameter.getValue())) {
            serviceMetaData.setDisableTryit(true);
        }

        return serviceMetaData;
    }
 
Example #22
Source File: IWADeploymentInterceptor.java    From carbon-identity with Apache License 2.0 2 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void serviceGroupUpdate(AxisEvent event, AxisServiceGroup group) {
}
 
Example #23
Source File: UrlMappingDeploymentInterceptor.java    From carbon-commons with Apache License 2.0 2 votes vote down vote up
public void serviceGroupUpdate(AxisEvent axisEvent, AxisServiceGroup axisServiceGroup) {

    }