public void destinationRemoved(Destination destination) throws ServiceException { synchronized (invalidKeys) { invalidKeys.add(SimpleServiceInvoker.class.getName() + '.' + destination.getId()); } }
public void destinationRemoved(Destination destination) throws ServiceException { synchronized (invalidKeys) { invalidKeys.add(SimpleServiceInvoker.class.getName() + '.' + destination.getId()); } }
protected ServiceException getServiceException(Message request, Destination destination, String method, Throwable e) { if (e instanceof ServiceException) return (ServiceException)e; String detail = "\n" + "- destination: " + (destination != null ? destination.getId() : "") + "\n" + "- method: " + method + "\n" + "- exception: " + e.toString() + "\n"; return new ServiceException(getClass().getSimpleName() + ".Call.Failed", e.getMessage(), detail, e); } }
@Override public ServiceInvoker<?> getServiceInstance(RemotingMessage request) throws ServiceException { String messageType = request.getClass().getName(); String destinationId = request.getDestination(); GraniteContext context = GraniteContext.getCurrentInstance(); Destination destination = ((ServicesConfig)context.getServicesConfig()).findDestinationById(messageType, destinationId); if (destination == null) throw new ServiceException("No matching destination: " + destinationId); destination.addRemoveListener(this); Map<String, Object> cache = getCache(destination); String key = SimpleServiceInvoker.class.getName() + '.' + destination.getId(); if (invalidKeys.contains(key)) { cache.remove(key); invalidKeys.remove(key); } SimpleServiceInvoker service = (SimpleServiceInvoker)cache.get(key); if (service == null) { service = new SimpleServiceInvoker(destination, this); cache.put(key, service); } return service; }
@Override public ServiceInvoker<?> getServiceInstance(RemotingMessage request) throws ServiceException { String messageType = request.getClass().getName(); String destinationId = request.getDestination(); GraniteContext context = GraniteContext.getCurrentInstance(); Destination destination = context.getServicesConfig().findDestinationById(messageType, destinationId); if (destination == null) throw new ServiceException("No matching destination: " + destinationId); destination.addRemoveListener(this); Map<String, Object> cache = getCache(destination); String key = SimpleServiceInvoker.class.getName() + '.' + destination.getId(); if (invalidKeys.contains(key)) { cache.remove(key); invalidKeys.remove(key); } SimpleServiceInvoker service = (SimpleServiceInvoker)cache.get(key); if (service == null) { service = new SimpleServiceInvoker(destination, this); cache.put(key, service); } return service; }
@Override protected Object afterInvocation(ServiceInvocationContext context, Object result) { if (metadata.isStateful() && metadata.isRemoveMethod(context.getMethod())) factory.removeFromCache(destination.getId()); return result; }
"- destination: " + (destination != null ? destination.getId() : "") + "\n" + "- method: " + method + "\n" + "- exception: " + t.toString() + "\n";
public EjbServiceInvoker(Destination destination, EjbServiceFactory factory) throws ServiceException { super(destination, factory); String lookup = factory.getLookup(); if (destination.getProperties().containsKey("lookup")) lookup = destination.getProperties().get("lookup"); // Compute EJB JNDI binding. String name = destination.getId(); if (lookup != null) { name = lookup; if (lookup.contains(CAPITALIZED_DESTINATION_ID)) name = lookup.replace(CAPITALIZED_DESTINATION_ID, capitalize(destination.getId())); if (lookup.contains(DESTINATION_ID)) name = lookup.replace(DESTINATION_ID, destination.getId()); } log.debug(">> New EjbServiceInvoker looking up: %s", name); try { invokee = factory.lookup(name); } catch (NamingException e) { throw new ServiceException("Could not lookup for: " + name, e); } this.metadata = destination.getScannedClass() != null ? new EjbServiceMetadata(destination.getScannedClass(), invokee.getClass()) : new EjbServiceMetadata(destination.getProperties(), invokee.getClass()); }
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); } }
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); } }
if (dest != null) { dest.remove(); log.info("RemoteDestination:"+dest.getId()+" has been removed");
if (dest != null) { dest.remove(); log.info("RemoteDestination:"+dest.getId()+" has been removed");
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); }
@Override protected void afterInvocationError(ServiceInvocationContext context, Throwable error) { // "A NoSuchEJBException is thrown if an attempt is made to invoke a method // on an object that no longer exists" (javadoc on NoSuchEJBException). if (error instanceof NoSuchEJBException || ( metadata.isStateful() && metadata.isRemoveMethod(context.getMethod()) && !metadata.getRetainIfException(context.getMethod()) )) factory.removeFromCache(destination.getId()); }
service.getDestinations().put(destination.getId(), destination);
service.getDestinations().put(destination.getId(), destination);
dmsg.setDestination(getDestination().getId());
String selector = gdd.getDestinationSelector(destination.getId()); log.debug("Session selector found: %s", selector); if (selector != null)