private VersionCheckHandler createVersionCheckHandler( ServerServiceId serverSvcId, ServiceConfigHolder config, ClassLoader cl) throws ServiceException { String currentVersion = config.getMetaData().getVersion(); if (currentVersion == null || currentVersion.length() == 0) { throw new ServiceCreationException( ErrorDataFactory.createErrorData( ErrorConstants.SVC_FACTORY_MISSING_SERVICE_VERSION, ErrorConstants.ERRORDOMAIN, new Object[] {serverSvcId.getAdminName()})); } Collection<String> supportedVersions = config.getSupportedVersions(); if (supportedVersions != null) { supportedVersions = new ArrayList<String>(supportedVersions); } else { supportedVersions = new ArrayList<String>(); } if (!supportedVersions.contains(currentVersion)) { supportedVersions.add(currentVersion); } supportedVersions = Collections.unmodifiableCollection(supportedVersions); String versionCheckClassName = config.getVersionCheckHandlerClassName(); if (versionCheckClassName == null) { versionCheckClassName = SimpleVersionCheckHandler.class.getName(); } VersionCheckHandler versionCheckHandler = ReflectionUtils.createInstance(versionCheckClassName, VersionCheckHandler.class, cl); VersionCheckHandlerInitContextImpl initCtx = new VersionCheckHandlerInitContextImpl(serverSvcId, currentVersion, supportedVersions); versionCheckHandler.init(initCtx); initCtx.kill(); return versionCheckHandler; }
public ServerServiceDesc createFallbackServiceDesc(QName serviceQName) throws ServiceException { ServerServiceId serverSvcId = ServerServiceId.createFallbackServiceId(serviceQName.getLocalPart()); ClassLoader cl = ServiceDesc.class.getClassLoader(); // create empty pipelines Pipeline requestPipeline = createFallbackPipeline(serverSvcId, PipelineMode.REQUEST); Pipeline responsePipeline = createFallbackPipeline(serverSvcId, PipelineMode.RESPONSE); // create empty operation lists Map<String, ServiceOperationDesc> operations = new HashMap<String, ServiceOperationDesc>(); RequestPatternMatcher<ServiceOperationDesc> operationMatcher = new RequestPatternMatcher<ServiceOperationDesc>(true); // create empty protocol processor lists Map<String, ProtocolProcessorDesc> protocols = new HashMap<String, ProtocolProcessorDesc>(); RequestPatternMatcher<ProtocolProcessorDesc> protocolMatcher = new RequestPatternMatcher<ProtocolProcessorDesc>(true); Set<Class> rootClasses = getRootClassesFromOperations(operations.values()); // create default bindings Map<String, DataBindingDesc> bindings = new HashMap<String, DataBindingDesc>(); addDefaultDataBindings(serverSvcId, bindings, null, rootClasses, null, true); // create matchers for bindings RequestPatternMatcher<DataBindingDesc> bindingMatcherForRequest = new RequestPatternMatcher<DataBindingDesc>(true); RequestPatternMatcher<DataBindingDesc> bindingMatcherForResponse = new RequestPatternMatcher<DataBindingDesc>(true); createDataBindingsMatchers( bindings.values(), bindingMatcherForRequest, bindingMatcherForResponse); ServiceTypeMappings typeMappings = createFallbackTypeMappings(); ErrorMapper errorMapper = new DefaultErrorMapperImpl(); ErrorDataProvider errorDataProviderClass = getDefaultErrorDataProviderClass(); ErrorMapperInitContextImpl errorMapperInitCtx = new ErrorMapperInitContextImpl(serverSvcId); errorMapper.init(errorMapperInitCtx); errorMapperInitCtx.kill(); List<LoggingHandler> loggingHandlers = new ArrayList<LoggingHandler>(); addDefaultLoggingHandler(serverSvcId, cl, loggingHandlers); Dispatcher requestDispatcher = new FallbackRequestDispatcher(); Dispatcher responseDispatcher = new SimpleServerResponseDispatcher(true); VersionCheckHandler versionCheckHandler = new NullVersionCheckHandler(); VersionCheckHandlerInitContextImpl versionInitCtx = new VersionCheckHandlerInitContextImpl(serverSvcId, "1.0", null); versionCheckHandler.init(versionInitCtx); versionInitCtx.kill(); Collection<GlobalIdEntry> registryEntries = GlobalRegistryConfigManager.getInstance().getAllEntries(); Map<String, GlobalIdDesc> globalIdMap = createGlobalIdMap(registryEntries, null); List<String> serviceLayers = ServiceConfigManager.getInstance().getGlobalConfig().getServiceLayerNames(); ServerServiceDesc result = new ServerServiceDesc( serverSvcId, serviceQName, null, // config requestPipeline, responsePipeline, requestDispatcher, responseDispatcher, operations, protocols, bindings, typeMappings, cl, loggingHandlers, null, // service interface class operationMatcher, protocolMatcher, bindingMatcherForRequest, bindingMatcherForResponse, null, // service impl class name errorMapper, errorDataProviderClass, globalIdMap, versionCheckHandler, null, UrlMappingsDesc.EMPTY_MAPPINGS, new OperationMappings(), HeaderMappingsDesc.EMPTY_MAPPINGS, HeaderMappingsDesc.EMPTY_MAPPINGS, Collections.unmodifiableMap(new HashMap<String, Map<String, String>>()), bindings.get(BindingConstants.PAYLOAD_XML), bindings.get(BindingConstants.PAYLOAD_XML), serviceLayers, null, null, null, null); return result; }