@Override protected Destination buildDestination(Adapter adapter) { Destination destination = super.buildDestination(adapter); destination.getProperties().put("server", null); destination.getProperties().put("server/broker-url", brokerUrl); destination.getProperties().put("server/create-broker", String.valueOf(createBroker)); if (createBroker) { destination.getProperties().put("server/wait-for-start", String.valueOf(waitForStart)); destination.getProperties().put("server/durable", String.valueOf(durable)); if (durable) destination.getProperties().put("server/file-store-root", fileStoreRoot); } return destination; } }
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()); }
protected Destination buildDestination(Adapter adapter) { List<String> channelIds = new ArrayList<String>(); channelIds.add("gravityamf"); Destination destination = new Destination(id, channelIds, new XMap(), roles, adapter, null); destination.getProperties().put("no-local", String.valueOf(noLocal)); destination.getProperties().put("session-selector", String.valueOf(sessionSelector)); if (getSecurizerClassName() != null) destination.getProperties().put("securizer", securizerClassName); if (getSecurizer() != null) destination.setSecurizer(getSecurizer()); return destination; } }
protected Destination buildDestination() { List<String> channelIds = new ArrayList<String>(); channelIds.add("graniteamf"); Destination destination = new Destination(source, channelIds, new XMap(), roles, null, null); if (securizer != null) destination.setSecurizer(securizer); return destination; } }
String key = OSGiServiceFactory.class.getName() + '.' + destination.getId(); String factoryId = destination.getProperties().get("factory"); if (factoryId == null) { GraniteDestination gd; synchronized (destinationServices) { gd = destinationServices.get(destination.getId()); throw new ServiceException("Could not get OSGi destination: " + destination.getId()); obj = gd; } else {
protected SimpleServiceInvoker(Destination destination, SimpleServiceFactory factory) throws ServiceException { super(destination, factory); String className = destination.getProperties().get("source"); if (className == null) throw new ServiceException("No source property for destination: " + destination); className = className.trim(); log.debug(">> New SimpleServiceInvoker constructing new: %s", className); // Invokee class set at runtime (RemoteObject.source). if ("*".equals(className)) sources = new HashMap<String, Object>(); else { try { if (destination.getScannedClass() != null) this.invokee = destination.getScannedClass().newInstance(); else this.invokee = TypeUtil.newInstance(className); } catch (Exception e) { throw new ServiceException("Invalid source property for destination: " + destination, e); } sources = null; } }
channelIds.add("graniteamf"); List<String> tideRoles = serverFilter.tideRoles().length == 0 ? null : Arrays.asList(serverFilter.tideRoles()); Destination destination = new Destination(type, channelIds, new XMap(), tideRoles, null, null); destination.getProperties().put("factory", "tide-" + type + "-factory"); if (!("".equals(serverFilter.entityManagerFactoryJndiName()))) destination.getProperties().put("entity-manager-factory-jndi-name", serverFilter.entityManagerFactoryJndiName()); else if (!("".equals(serverFilter.entityManagerJndiName()))) destination.getProperties().put("entity-manager-jndi-name", serverFilter.entityManagerJndiName()); if (!("".equals(serverFilter.validatorClassName()))) destination.getProperties().put("validator-class-name", serverFilter.validatorClassName()); service.getDestinations().put(type, destination); if (destination.getSecurizer() == null && configProvider != null) { RemotingDestinationSecurizer securizer = configProvider.findInstance(RemotingDestinationSecurizer.class); destination.setSecurizer(securizer);
public void destinationRemoved(Destination destination) throws ServiceException { synchronized (invalidKeys) { invalidKeys.add(SimpleServiceInvoker.class.getName() + '.' + destination.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 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; }
props.put("securizer", anno.securizer().getName()); Destination destination = new Destination(anno.id(), channelIds, props, roles, null, clazz); service.getDestinations().put(destination.getId(), destination);
log.debug(">> No cached factory for: %s", adapterId); Adapter config = destination.getAdapter(); try { Class<? extends ServiceAdapter> clazz = (adapterId != null) serviceAdapter.setId(adapterId); serviceAdapter.setGravity(gravity); serviceAdapter.configure(config.getProperties(), destination.getProperties()); serviceAdapter.start(); log.debug(">> Found a cached serviceAdapter for ref: %s", destination.getAdapter());
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); }
if (destination.getSecurizer() instanceof GravityDestinationSecurizer) { try { ((GravityDestinationSecurizer)destination.getSecurizer()).canPublish(invocationContext);
public static Destination forElement(XMap element, Adapter defaultAdapter, Map<String, Adapter> adaptersMap) { String id = element.get("@id"); List<String> channelRefs = new ArrayList<String>(); for (XMap channel : element.getAll("channels/channel[@ref]")) channelRefs.add(channel.get("@ref")); XMap properties = new XMap(element.getOne("properties")); List<String> rolesList = null; if (element.containsKey("security/security-constraint/roles/role")) { rolesList = new ArrayList<String>(); for (XMap role : element.getAll("security/security-constraint/roles/role")) rolesList.add(role.get(".")); } XMap adapter = element.getOne("adapter[@ref]"); Adapter adapterRef = adapter != null && adaptersMap != null ? adaptersMap.get(adapter.get("@ref")) : defaultAdapter; return new Destination(id, channelRefs, properties, rolesList, adapterRef, null); } }
if (Boolean.TRUE.toString().equals(destination.getProperties().get("session-selector"))) { String selector = gdd.getDestinationSelector(destination.getId()); log.debug("Session selector found: %s", selector); if (selector != null)
protected SimpleServiceInvoker(Destination destination, SimpleServiceFactory factory) throws ServiceException { super(destination, factory); String className = destination.getProperties().get("source"); if (className == null) throw new ServiceException("No source property for destination: " + destination); className = className.trim(); log.debug(">> New SimpleServiceInvoker constructing new: %s", className); // Invokee class set at runtime (RemoteObject.source). if ("*".equals(className)) sources = new HashMap<String, Object>(); else { try { if (destination.getScannedClass() != null) this.invokee = destination.getScannedClass().newInstance(); else this.invokee = TypeUtil.newInstance(className); } catch (Exception e) { throw new ServiceException("Invalid source property for destination: " + destination, e); } sources = null; } }
public void destinationRemoved(Destination destination) throws ServiceException { synchronized (invalidKeys) { invalidKeys.add(SimpleServiceInvoker.class.getName() + '.' + destination.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); } }