public EjbServiceMetadata(XMap properties, Class<?> invokeeClass) { stateful = properties.containsKey("ejb-stateful"); if (stateful) { for (XMap removeMethod : properties.getAll("ejb-stateful/remove-method")) { String signature = removeMethod.get("signature"); if (signature == null) throw new ServiceException("Missing signature in remove-method declaration: " + properties); Boolean retainIfException = Boolean.valueOf(removeMethod.get("retain-if-exception")); try { removeMethods.put(TypeUtil.getMethod(invokeeClass, signature), retainIfException); } catch (NoSuchMethodException e) { throw new ServiceException("Could not find method: " + invokeeClass.getName() + "." + signature); } } } }
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); } }
@Override public ServiceInvoker<?> getServiceInstance(RemotingMessage request) throws ServiceException { String messageType = request.getClass().getName(); String destinationId = request.getDestination(); ServicesConfig servicesConfig = GraniteContext.getCurrentInstance().getServicesConfig(); Destination destination = servicesConfig.findDestinationById(messageType, destinationId); if (destination == null) throw new ServiceException("No matching destination: " + destinationId); if (!destination.getProperties().containsKey(TideServiceInvoker.VALIDATOR_CLASS_NAME)) destination.getProperties().put(TideServiceInvoker.VALIDATOR_CLASS_NAME, "org.granite.tide.validation.BeanValidation"); @SuppressWarnings("unchecked") Bean<PersistenceConfiguration> pcBean = (Bean<PersistenceConfiguration>)manager.getBeans(PersistenceConfiguration.class).iterator().next(); PersistenceConfiguration persistenceConfiguration = (PersistenceConfiguration)manager.getReference(pcBean, PersistenceConfiguration.class, manager.createCreationalContext(pcBean)); if (destination.getProperties().containsKey(ENTITY_MANAGER_FACTORY_JNDI_NAME)) persistenceConfiguration.setEntityManagerFactoryJndiName(destination.getProperties().get(ENTITY_MANAGER_FACTORY_JNDI_NAME)); else if (destination.getProperties().containsKey(ENTITY_MANAGER_JNDI_NAME)) persistenceConfiguration.setEntityManagerJndiName(destination.getProperties().get(ENTITY_MANAGER_JNDI_NAME)); // Create an instance of the component CDIServiceInvoker invoker = new CDIServiceInvoker(destination, this); return invoker; } }
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); } }
private ServiceInvoker<?> getServiceInvoker(Map<String, Object> cache, Destination destination, String key) { GraniteContext context = GraniteContext.getCurrentInstance(); synchronized (context.getSessionLock()) { ServiceInvoker<?> invoker = (ServiceInvoker<?>)cache.get(key); if (invoker == null) { String lookup = getLookup(); if (destination.getProperties().containsKey("lookup")) lookup = destination.getProperties().get("lookup"); EjbServiceContext tideContext = new EjbServiceContext(lookup, initialContext); if (destination.getProperties().containsKey(ENTITY_MANAGER_FACTORY_JNDI_NAME)) { tideContext.setEntityManagerFactoryJndiName(destination.getProperties().get(ENTITY_MANAGER_FACTORY_JNDI_NAME)); } else if (destination.getProperties().containsKey(ENTITY_MANAGER_JNDI_NAME)) { tideContext.setEntityManagerJndiName(destination.getProperties().get(ENTITY_MANAGER_JNDI_NAME)); } invoker = new TideServiceInvoker<EjbServiceFactory>(destination, this, tideContext); cache.put(key, invoker); } return invoker; } } }
if (destinationProperties.containsKey("server/file-store-root")) sb.append("&broker.dataDirectory=").append(destinationProperties.get("server/file-store-root"));
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()); }
useUdp = config.containsKey("udp"); if (useUdp) { udpPort = config.get("udp/@port", Integer.TYPE, 0);