@Override public String getOutputDestination() { if(outputDestination == null) { return null; } return outputDestination.getValue(); } /* (non-Javadoc)
@Override public String marshal(ModuleURN inURN) throws Exception { return inURN.getValue(); } }
@Override public String toString() { return getValue(); }
/** * Converts an array of module URN values to an array of strings. * If the supplied value is null, the returned value is null. * * @param inURNs the array of module URNs. * * @return the array of string values of the module URN. */ private List<String> toString(List<ModuleURN> inURNs) { if(inURNs == null) { return null; } ArrayList<String> list = new ArrayList<String>(inURNs.size()); for(ModuleURN urn: inURNs) { list.add(urn.getValue()); } return list; }
/** * Creates an instance. * * @param inModuleURN the URN of the module throwing this error. * @param inParameter the offending parameter value. */ public UnsupportedRequestParameterType(ModuleURN inModuleURN, Object inParameter) { super(new I18NBoundMessage2P(Messages.UNSUPPORTED_REQ_PARM_TYPE, inModuleURN.getValue(), inParameter == null ? String.valueOf(null) :inParameter.getClass().getName())); } }
/** * Creates an instance. * * @param inModuleURN the module throwing this exception * @param inParameter the offending parameter value */ public IllegalRequestParameterValue(ModuleURN inModuleURN, Object inParameter) { super(new I18NBoundMessage2P(Messages.ILLEGAL_REQ_PARM_VALUE, inModuleURN.getValue(), ObjectUtils.toString(inParameter,null))); }
/** * Creates an instance * * @param inModuleURN the module throwing this exception * @param inParameter the parameter value * @param inCause the cause */ public IllegalRequestParameterValue(ModuleURN inModuleURN, Object inParameter, Throwable inCause) { super(inCause, new I18NBoundMessage2P(Messages.ILLEGAL_REQ_PARM_VALUE, inModuleURN.getValue(), ObjectUtils.toString(inParameter,null))); } }
@Override public String createModule(String providerURN, String parameters) { try { ModuleURN urn = mManager.createModuleJMX( new ModuleURN(providerURN), parameters); return urn.getValue(); } catch (ModuleException e) { throw transformFailure(e); } }
@Override public List<ModuleURN> getInstances(ModuleURN inProviderURN) throws ConnectionException { failIfDisconnected(); try { RpcSAClient.InstancesResponse response = clientService.getInstances(controller, RpcSAClient.InstancesRequest.newBuilder().setSessionId(sessionId.getValue()) .setProvider(RpcSAClient.ModuleURN.newBuilder().setValue(inProviderURN.getValue())).build()); List<ModuleURN> instances = Lists.newArrayList(); for(RpcSAClient.ModuleURN instance : response.getInstanceList()) { instances.add(new ModuleURN(instance.getValue())); } return instances; } catch (ServiceException e) { throw wrapRemoteFailure(e); } } /* (non-Javadoc)
@Override public void start(ModuleURN inURN) throws ConnectionException { failIfDisconnected(); try { clientService.start(controller, RpcSAClient.StartRequest.newBuilder().setSessionId(sessionId.getValue()) .setInstance(RpcSAClient.ModuleURN.newBuilder().setValue(inURN.getValue())).build()); return; } catch (ServiceException e) { throw wrapRemoteFailure(e); } } /* (non-Javadoc)
@Override public Map<String,Object> getProperties(ModuleURN inURN) throws ConnectionException { failIfDisconnected(); try { RpcSAClient.GetPropertiesResponse response = clientService.getProperties(controller, RpcSAClient.GetPropertiesRequest.newBuilder().setSessionId(sessionId.getValue()) .setInstance(RpcSAClient.ModuleURN.newBuilder().setValue(inURN.getValue())).build()); Map<String,Object> properties = Maps.newHashMap(); for(RpcSAClient.Entry entry : response.getProperties().getEntryList()) { String key = entry.getKey(); Object value = ((XmlValue)unmarshal(entry.getValue())).getValue(); properties.put(key, value); } return properties; } catch (ServiceException | JAXBException e) { throw wrapRemoteFailure(e); } } /* (non-Javadoc)
@Override public void stop(ModuleURN inURN) throws ConnectionException { failIfDisconnected(); try { clientService.stop(controller, RpcSAClient.StopRequest.newBuilder().setSessionId(sessionId.getValue()) .setInstance(RpcSAClient.ModuleURN.newBuilder().setValue(inURN.getValue())).build()); return; } catch (ServiceException e) { throw wrapRemoteFailure(e); } } /* (non-Javadoc)
@Override public void delete(ModuleURN inURN) throws ConnectionException { failIfDisconnected(); try { clientService.delete(controller, RpcSAClient.DeleteRequest.newBuilder().setSessionId(sessionId.getValue()) .setInstance(RpcSAClient.ModuleURN.newBuilder().setValue(inURN.getValue())).build()); return; } catch (ServiceException e) { throw wrapRemoteFailure(e); } } /* (non-Javadoc)
.setInstance(RpcSAClient.ModuleURN.newBuilder().setValue(inURN.getValue())) .setProperties(propertiesBuilder.build()).build()); Map<String,Object> properties = Maps.newHashMap();
@Override public ProvidersResponse getProviders(RpcController inController, ProvidersRequest inRequest) throws ServiceException { serverServices.validateAndReturnSession(inRequest.getSessionId()); SLF4JLoggerProxy.debug(this, "{} received getProviders request", DESCRIPTION); List<ModuleURN> providers = serviceAdapter.getProviders(); RpcSAClient.ProvidersResponse.Builder responseBuilder = RpcSAClient.ProvidersResponse.newBuilder(); if(providers != null) { for(ModuleURN provider : providers) { responseBuilder.addProvider(RpcSAClient.ModuleURN.newBuilder().setValue(provider.getValue()).build()); } } RpcSAClient.ProvidersResponse response = responseBuilder.build(); SLF4JLoggerProxy.debug(this, "{} returning {}", DESCRIPTION, providers); return response; } /* (non-Javadoc)
@Override public CreateStrategyParameters getStrategyCreateParms(ModuleURN inURN) throws ConnectionException { failIfDisconnected(); try { RpcSAClient.StrategyCreateParmsResponse response = clientService.getStrategyCreateParms(controller, RpcSAClient.StrategyCreateParmsRequest.newBuilder().setSessionId(sessionId.getValue()) .setInstance(RpcSAClient.ModuleURN.newBuilder().setValue(inURN.getValue())).build()); CreateStrategyParameters params = unmarshal(response.getCreateStrategyParameters().getPayload()); return params; } catch (ServiceException | JAXBException e) { throw wrapRemoteFailure(e); } } /* (non-Javadoc)
@Override public ModuleInfo getModuleInfo(ModuleURN inURN) throws ConnectionException { failIfDisconnected(); try { RpcSAClient.ModuleInfoResponse response = clientService.getModuleInfo(controller, RpcSAClient.ModuleInfoRequest.newBuilder().setSessionId(sessionId.getValue()) .setInstance(RpcSAClient.ModuleURN.newBuilder().setValue(inURN.getValue())).build()); ModuleInfo info = null; if(response.hasInfo()) { info = unmarshal(response.getInfo().getPayload()); } return info; } catch (ServiceException | JAXBException e) { throw wrapRemoteFailure(e); } } /* (non-Javadoc)
@Override public CreateStrategyResponse createStrategy(RpcController inController, CreateStrategyRequest inRequest) throws ServiceException { serverServices.validateAndReturnSession(inRequest.getSessionId()); CreateStrategyParameters parameters; try { parameters = serverServices.unmarshall(inRequest.getCreateStrategyParameters().getPayload()); } catch (JAXBException e) { throw new ServiceException(e); } SLF4JLoggerProxy.debug(this, "{} received createStrategy with {} request", DESCRIPTION, parameters); ModuleURN instance = serviceAdapter.createStrategy(parameters); RpcSAClient.CreateStrategyResponse.Builder responseBuilder = RpcSAClient.CreateStrategyResponse.newBuilder(); responseBuilder.setInstance(RpcSAClient.ModuleURN.newBuilder().setValue(instance.getValue())); RpcSAClient.CreateStrategyResponse response = responseBuilder.build(); SLF4JLoggerProxy.debug(this, "{} returning {}", DESCRIPTION, instance); return response; } /* (non-Javadoc)
getURN().getValue(), type, source,
@Override public InstancesResponse getInstances(RpcController inController, InstancesRequest inRequest) throws ServiceException { serverServices.validateAndReturnSession(inRequest.getSessionId()); ModuleURN provider = new ModuleURN(inRequest.getProvider().getValue()); SLF4JLoggerProxy.debug(this, "{} received getInstances for {} request", DESCRIPTION, provider); List<ModuleURN> instances = serviceAdapter.getInstances(provider); RpcSAClient.InstancesResponse.Builder responseBuilder = RpcSAClient.InstancesResponse.newBuilder(); if(instances != null) { for(ModuleURN instance : instances) { responseBuilder.addInstance(RpcSAClient.ModuleURN.newBuilder().setValue(instance.getValue()).build()); } } RpcSAClient.InstancesResponse response = responseBuilder.build(); SLF4JLoggerProxy.debug(this, "{} returning {}", DESCRIPTION, instances); return response; } /* (non-Javadoc)