public String getBrokerUrl() { return connectionDescriptor.getLocation().toString(); }
private void processManagerDescriptor(ServiceManagerDescriptor managerDescriptor) throws MalformedURLException, URISyntaxException { for (ConnectionDescriptor descriptor : managerDescriptor.getServiceLocations()) { if ("jmx".equals(descriptor.getProtocol())) { URI oldLocationUri = descriptor.getLocation(); URI newLocationUri = processJmxURI(oldLocationUri); descriptor.setLocation(newLocationUri); } else { descriptor.setLocation( new URIBuilder(descriptor.getLocation()).setPort(descriptor.getLocation().getPort() + portShift).build()); } } } }
@RequestMapping(value="/containers/add", method=RequestMethod.POST) public String addContainer(final Model model, @ModelAttribute("containerDescriptor") ServiceDescriptor containerDescriptor, BindingResult result) { containerDescriptorValidator.validate(containerDescriptor, result); if (result.hasErrors()) { model.addAttribute("availableServiceProtocols", ServiceRegistryConstants.ALL_KNOWN_SERVICE_PROTOCOLS); return "console.platform.container.add"; } ListIterator<ConnectionDescriptor> it = containerDescriptor.getServiceLocations().listIterator(); while (it.hasNext()) { ConnectionDescriptor conn = it.next(); if (conn.getLocation() == null || conn.getProtocol() == null) { it.remove(); } } registryManager.addContainer(containerDescriptor); return UrlBasedViewResolver.REDIRECT_URL_PREFIX + "/containers"; }
@SuppressWarnings("unchecked") @Override protected <T> T createService(ConnectionDescriptor connectionDescriptor, Class<T> serviceInterface, String serviceId, boolean stateful) { final URI location = connectionDescriptor.getLocation(); final ServiceRestClient restClient = getRestClientByInterface(serviceInterface); if (restClient == null) { logger.error("Could not find client for " + serviceInterface); return null; } else { injectValues(location, restClient); restClient.initialize(); return (T) restClient; } }
public Object invokeOperation(ServiceManagerDescriptor managerDescriptor, String operationName, Object[] params, String[] signature) { ConnectionDescriptor connectionDescriptor = findLocation(managerDescriptor); String serverUrl = connectionDescriptor.getLocation().toString(); String objectNameString = connectionDescriptor.getProtocolFeatures().get("objectName"); try { MBeanServerConnection serverConnection; serverConnection = connectorFactory.getMBeanServerConnection(serverUrl); ObjectName objectName = ObjectNameManager.getInstance(objectNameString); return serverConnection.invoke(objectName, operationName, params, signature); } catch (Exception e) { throw new MBeanConnectFailureException("Exception while retrieving MBeanInfo", e); } }
public Object createProxy(ServiceManagerDescriptor managerDescriptor) { String managerType = managerDescriptor.getManagerType(); Class<?> managerInterface; try { managerInterface = beanClassloader.loadClass(managerType); } catch (ClassNotFoundException e) { logger.error("Manager Interface not found [{}]", managerType, e); throw new GeneralServiceException(e); } ConnectionDescriptor connectionDescriptor = findLocation(managerDescriptor); String serverUrl = connectionDescriptor.getLocation().toString(); String objectName = connectionDescriptor.getProtocolFeatures().get("objectName"); return createProxyWithInterface(serverUrl, objectName, managerInterface); }
private ContainerDetails transformToContainerDetails(final ServiceDescriptor containerDescriptor) { ContainerDetails containerDetails = new ContainerDetails(); containerDetails.setName(containerDescriptor.getServiceId()); List<String> locations = new ArrayList<String>(); List<ConnectionDescriptor> serviceLocations = containerDescriptor.getServiceLocations(); if (serviceLocations != null) { for (ConnectionDescriptor connectionDescriptor : serviceLocations) { locations.add(connectionDescriptor.getLocation().toString()); } } containerDetails.setAddress(locations); return containerDetails; }
public Object getAttribute(ServiceManagerDescriptor managerDescriptor, String attributeName) { ConnectionDescriptor connectionDescriptor = findLocation(managerDescriptor); String serverUrl = connectionDescriptor.getLocation().toString(); String objectNameString = connectionDescriptor.getProtocolFeatures().get("objectName"); try { MBeanServerConnection serverConnection; serverConnection = connectorFactory.getMBeanServerConnection(serverUrl); ObjectName objectName = ObjectNameManager.getInstance(objectNameString); return serverConnection.getAttribute(objectName, attributeName); } catch (Exception e) { throw new MBeanConnectFailureException("Exception while retrieving MBeanInfo", e); } } }
private ConnectionDescriptorProto transformConnectionDesc(final ConnectionDescriptor connectionDescriptor) { pl.edu.icm.synat.api.services.registry.model.protobuf.ServicesModel.ConnectionDescriptorProto.Builder builder; builder = ConnectionDescriptorProto.newBuilder(); builder.addAllFeatures(transformMap(connectionDescriptor.getProtocolFeatures())); if (connectionDescriptor.getLocation() != null) { builder.setLocation(connectionDescriptor.getLocation().toString()); } builder.setProtocol(connectionDescriptor.getProtocol()); return builder.build(); }
public MBeanInfo getMBeanInfo(ServiceManagerDescriptor managerDescriptor) { ConnectionDescriptor connectionDescriptor = findLocation(managerDescriptor); String serverUrl = connectionDescriptor.getLocation().toString(); String objectName = connectionDescriptor.getProtocolFeatures().get("objectName"); try { MBeanServerConnection serverConnection; serverConnection = connectorFactory.getMBeanServerConnection(serverUrl); MBeanInfo mBeanInfo = serverConnection.getMBeanInfo(ObjectNameManager.getInstance(objectName)); return mBeanInfo; } catch (Exception e) { throw new MBeanConnectFailureException("Exception while retrieving MBeanInfo", e); } }
@Override protected <T> T createService(ConnectionDescriptor connectionDescriptor, Class<T> serviceInterface, String serviceId, boolean stateful) { final RmiProxyFactoryBean proxyFactoryBean = new RmiProxyFactoryBean(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); proxyFactoryBean.setBeanClassLoader(classLoader); proxyFactoryBean.setServiceInterface(serviceInterface); proxyFactoryBean.setLookupStubOnStartup(true); proxyFactoryBean.setServiceUrl(connectionDescriptor.getLocation().toString()); proxyFactoryBean.afterPropertiesSet(); @SuppressWarnings("unchecked") final T service = clientInterceptorUtil.addHttpInterceptors((T) proxyFactoryBean.getObject(), connectionDescriptor); return service; } }
@Override protected <T> T createService(ConnectionDescriptor connectionDescriptor, Class<T> serviceInterface, String serviceId, boolean stateful) { final HessianProxyFactoryBean proxyFactoryBean = new HessianProxyFactoryBean(); proxyFactoryBean.setServiceInterface(serviceInterface); proxyFactoryBean.setServiceUrl(connectionDescriptor.getLocation().toString()); final HessianConnectionFactory factory = new StatefulHessianConnectionFactory(serviceSecurityContext); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); final HessianProxyFactory proxyFactory = new HessianProxyFactory(classLoader); factory.setHessianProxyFactory(proxyFactory); proxyFactory.setConnectionFactory(factory); proxyFactoryBean.setProxyFactory(proxyFactory); proxyFactoryBean.afterPropertiesSet(); @SuppressWarnings("unchecked") final T service = clientInterceptorUtil.addHttpInterceptors((T) proxyFactoryBean.getObject(), connectionDescriptor); return service; }
@Override protected <T> T createService(ConnectionDescriptor connectionDescriptor, Class<T> serviceInterface, String serviceId, boolean stateful) { final HttpInvokerProxyFactoryBean proxyFactoryBean = new HttpInvokerProxyFactoryBean(); proxyFactoryBean.setServiceInterface(serviceInterface); proxyFactoryBean.setServiceUrl(connectionDescriptor.getLocation().toString()); final HttpInvokerRequestExecutor executor; final HttpClient httpClient = createHttpClient(); if (stateful) { executor = new SessionInvokerRequestExecutor(httpClient, serviceSecurityContext, requestConfig); } else { executor = new DefaultHttpInvokerRequestExecutor(httpClient, serviceSecurityContext, requestConfig); } if (executor instanceof BeanClassLoaderAware) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ((BeanClassLoaderAware) executor).setBeanClassLoader(classLoader); } proxyFactoryBean.setHttpInvokerRequestExecutor(executor); proxyFactoryBean.afterPropertiesSet(); @SuppressWarnings("unchecked") final T service = clientInterceptorUtil.addHttpInterceptors((T) proxyFactoryBean.getObject(), connectionDescriptor); return service; }