@Override public String toString() { return "Service{" + "id=" + id + ", class=" + className + ", messageTypes=" + messageTypes + ", defaultAdapter=" + adapter.getId() + '}'; } }
public static Service forElement(XMap element) { String id = element.get("@id"); String className = element.get("@class"); String messageTypes = element.get("@messageTypes"); Adapter defaultAdapter = null; Map<String, Adapter> adaptersMap = new HashMap<String, Adapter>(); for (XMap adapter : element.getAll("adapters/adapter-definition")) { Adapter ad = Adapter.forElement(adapter); if (Boolean.TRUE.toString().equals(adapter.get("@default"))) defaultAdapter = ad; adaptersMap.put(ad.getId(), ad); } Map<String, Destination> destinations = new HashMap<String, Destination>(); for (XMap destinationElt : element.getAll("destination")) { Destination destination = Destination.forElement(destinationElt, defaultAdapter, adaptersMap); destinations.put(destination.getId(), destination); } return new Service(id, className, messageTypes, defaultAdapter, adaptersMap, destinations); } }
@Override protected Adapter buildAdapter() { return new Adapter("activemq-adapter", "org.granite.gravity.adapters.ActiveMQServiceAdapter", new XMap()); }
try { Class<? extends ServiceAdapter> clazz = (adapterId != null) ? TypeUtil.forName(config.getClassName(), ServiceAdapter.class) : defaultAdapterClass; serviceAdapter = clazz.newInstance(); serviceAdapter.setId(adapterId); serviceAdapter.setGravity(gravity); serviceAdapter.configure(config.getProperties(), destination.getProperties()); serviceAdapter.start();
public static Service forElement(XMap element) { String id = element.get("@id"); String className = element.get("@class"); String messageTypes = element.get("@messageTypes"); Adapter defaultAdapter = null; Map<String, Adapter> adaptersMap = new HashMap<String, Adapter>(); for (XMap adapter : element.getAll("adapters/adapter-definition")) { Adapter ad = Adapter.forElement(adapter); if (Boolean.TRUE.toString().equals(adapter.get("@default"))) defaultAdapter = ad; adaptersMap.put(ad.getId(), ad); } Map<String, Destination> destinations = new HashMap<String, Destination>(); for (XMap destinationElt : element.getAll("destination")) { Destination destination = Destination.forElement(destinationElt, defaultAdapter, adaptersMap); destinations.put(destination.getId(), destination); } return new Service(id, className, messageTypes, defaultAdapter, adaptersMap, destinations); } }
@Override protected Adapter buildAdapter() { return new Adapter("jms-adapter", "org.granite.gravity.adapters.JMSServiceAdapter", new XMap()); }
public void addAdapter(Adapter adapter) { adapters.put(adapter.getId(), adapter); }
protected Adapter buildAdapter() { return new Adapter("simple-adapter", "org.granite.gravity.adapters.SimpleServiceAdapter", new XMap()); }
public void addAdapter(Adapter adapter) { adapters.put(adapter.getId(), adapter); }
public static Adapter forElement(XMap element) { String id = element.get("@id"); String className = element.get("@class"); XMap properties = new XMap(element.getOne("properties")); return new Adapter(id, className, properties); } }
@Override public String toString() { return "Destination{" + "id='" + id + '\'' + ", service='" + service.getId() + '\'' + ", adapter='" + adapter.getId() + '\'' + '}'; } }
public static Adapter forElement(XMap element) { String id = element.get("@id"); String className = element.get("@class"); XMap properties = new XMap(element.getOne("properties")); return new Adapter(id, className, properties); } }
public ServiceAdapter getServiceAdapter(String messageType, String destinationId) throws ServiceException { GraniteContext context = GraniteContext.getCurrentInstance(); log.debug(">> Finding serviceAdapter for messageType: %s and destinationId: %s", messageType, destinationId); ServicesConfig servicesConfig = context.getServicesConfig(); Destination destination = servicesConfig.findDestinationById(messageType, destinationId); if (destination == null) { log.debug(">> No destination found: %s", destinationId); return null; } Adapter adapter = destination.getAdapter(); String key = null; if (adapter != null) { log.debug(">> Found adapterRef: %s", adapter.getId()); key = AdapterFactory.class.getName() + '@' + destination.getId() + '.' + adapter.getId(); } else key = defaultAdapterClass.getName() + '@' + destination.getId(); return getServiceAdapter(adaptersCache, context, destination, key, adapter != null ? adapter.getId() : null); }
adapter = buildAdapter(); Map<String, Adapter> adapters = new HashMap<String, Adapter>(); adapters.put(adapter.getId(), adapter); service = new Service("gravity-service", "flex.messaging.services.MessagingService", "flex.messaging.messages.AsyncMessage", adapter, adapters, new HashMap<String, Destination>()); service = services.get(0); Adapter ad = buildAdapter(); adapter = service.findAdapterById(ad.getId()); if (adapter == null) { adapter = ad;