public SmooksResourceConfigurationList registerResources(String baseURI, InputStream resourceConfigStream) throws SAXException, IOException, URISyntaxException { SmooksResourceConfigurationList configList; if(baseURI == null || baseURI.trim().equals("")) { throw new IllegalArgumentException("null or empty 'name' arg in method call."); } if(resourceConfigStream == null) { throw new IllegalArgumentException("null 'resourceConfigStream' arg in method call."); } configList = XMLConfigDigester.digestConfig(resourceConfigStream, baseURI, applicationContext.getClassLoader()); addSmooksResourceConfigurationList(configList); return configList; }
public void attachGlobalParameters(ApplicationContext appContext) { if(globalParams == null) { globalParams = appContext.getStore().getGlobalParams(); } }
public SmooksResourceConfigurationStore getStore() { SmooksResourceConfigurationStore cdrarStore = (SmooksResourceConfigurationStore)getAttribute(STORE_KEY); if(cdrarStore == null) { cdrarStore = new SmooksResourceConfigurationStore(this); setAttribute(STORE_KEY, cdrarStore); } return cdrarStore; }
/** * Add a {@link SmooksResourceConfigurationList} to this store. * * @param resourceList All the SmooksResourceConfigurationList instances added on this store. */ public void addSmooksResourceConfigurationList(SmooksResourceConfigurationList resourceList) { processAppContextInitializers(resourceList); configLists.add(resourceList); // XSD v1.0 added profiles to the resource config. If there were any, add them to the // profile store. addProfileSets(resourceList.getProfiles()); }
private void fireEvent(ContentDeliveryConfigBuilderLifecycleEvent event) { List<Object> initializedObjects = applicationContext.getStore().getInitializedObjects(); for(Object object : initializedObjects) { if(object instanceof ContentDeliveryConfigBuilderLifecycleListener) { ((ContentDeliveryConfigBuilderLifecycleListener) object).handle(event); } } }
/** * Try create the CDU creator for the specified resource type. * * Return null if unsuccessful i.e. no exceptions. * @param restype The resource type. * @return The appropriate CDU creator instance, or null if there is none. */ private ContentHandlerFactory tryCreateCreator(String restype) { ContentHandlerFactory creator; try { if(restype == null || restype.trim().equals("")) { logger.debug("Request to attempt ContentHandlerFactory creation based on a null/empty resource type."); return null; } creator = store.getContentHandlerFactory(restype); } catch (UnsupportedContentHandlerTypeException e) { return null; } return creator; }
/** * Get a list {@link Object}s from the supplied {@link org.milyn.cdr.SmooksResourceConfiguration} selector value. * * Uses {@link org.milyn.cdr.SmooksResourceConfigurationStore#getObject(org.milyn.cdr.SmooksResourceConfiguration)} to construct the object. * @param selector selector attribute value from the .cdrl file in the .cdrar. * @return List of Object instances. An empty list is returned where no * selectors exist. */ public List getObjects(String selector) { Vector objects; objects = (Vector)objectsTable.get(selector); if(objects == null) { List unitDefs = resourceConfigTable.get(selector); if(unitDefs != null && unitDefs.size() > 0) { objects = new Vector(unitDefs.size()); if(applicationContext == null) { throw new IllegalStateException("Call to getObjects() before the setApplicationContext() was called."); } for(int i = 0; i < unitDefs.size(); i++) { SmooksResourceConfiguration resConfig = (SmooksResourceConfiguration)unitDefs.get(i); objects.add(applicationContext.getStore().getObject(resConfig)); } } else { objects = EMPTY_LIST; } objectsTable.put(selector, objects); } return objects; }
private void registerInstalledHandlerFactories() { for (Class<ContentHandlerFactory> handlerFactory : handlerFactories) { Resource resourceAnnotation = handlerFactory.getAnnotation(Resource.class); if(resourceAnnotation != null) { addHandlerFactoryConfig(handlerFactory, resourceAnnotation.type()); } } // And add the Java handler... addHandlerFactoryConfig(JavaContentHandlerFactory.class, "class"); }
/** * Close this Smooks instance and all associated resources. * <p/> * Should result in the {@link org.milyn.delivery.annotation.Uninitialize uninitialization} * of all allocated {@link org.milyn.delivery.ContentHandler} instances. */ public void close() { context.getStore().close(); }
public static void removeParameter(String name, Smooks smooks) { SmooksResourceConfigurationStore configStore = smooks.getApplicationContext().getStore(); Iterator<SmooksResourceConfigurationList> configLists = configStore.getSmooksResourceConfigurationLists(); while(configLists.hasNext()) { SmooksResourceConfigurationList list = configLists.next(); for(int i = 0; i < list.size(); i++) { SmooksResourceConfiguration nextConfig = list.get(i); if(ParameterAccessor.GLOBAL_PARAMETERS.equals(nextConfig.getSelector())) { nextConfig.removeParameter(name); } } } } }
/** * Add a {@link SmooksResourceConfigurationList} to this store. * * @param resourceList All the SmooksResourceConfigurationList instances added on this store. */ public void addSmooksResourceConfigurationList(SmooksResourceConfigurationList resourceList) { processAppContextInitializers(resourceList); configLists.add(resourceList); // XSD v1.0 added profiles to the resource config. If there were any, add them to the // profile store. addProfileSets(resourceList.getProfiles()); }
private void fireEvent(ContentDeliveryConfigBuilderLifecycleEvent event) { List<Object> initializedObjects = applicationContext.getStore().getInitializedObjects(); for(Object object : initializedObjects) { if(object instanceof ContentDeliveryConfigBuilderLifecycleListener) { ((ContentDeliveryConfigBuilderLifecycleListener) object).handle(event); } } }
/** * Try create the CDU creator for the specified resource type. * <p/> * Return null if unsuccessful i.e. no exceptions. * @param restype The resource type. * @return The appropriate CDU creator instance, or null if there is none. */ private ContentHandlerFactory tryCreateCreator(String restype) { ContentHandlerFactory creator; try { if(restype == null || restype.trim().equals("")) { logger.debug("Request to attempt ContentHandlerFactory creation based on a null/empty resource type."); return null; } creator = store.getContentHandlerFactory(restype); } catch (UnsupportedContentHandlerTypeException e) { return null; } return creator; }
/** * Get a list {@link Object}s from the supplied {@link org.milyn.cdr.SmooksResourceConfiguration} selector value. * <p/> * Uses {@link org.milyn.cdr.SmooksResourceConfigurationStore#getObject(org.milyn.cdr.SmooksResourceConfiguration)} to construct the object. * @param selector selector attribute value from the .cdrl file in the .cdrar. * @return List of Object instances. An empty list is returned where no * selectors exist. */ public List getObjects(String selector) { Vector objects; objects = (Vector)objectsTable.get(selector); if(objects == null) { List unitDefs = resourceConfigTable.get(selector); if(unitDefs != null && unitDefs.size() > 0) { objects = new Vector(unitDefs.size()); if(applicationContext == null) { throw new IllegalStateException("Call to getObjects() before the setApplicationContext() was called."); } for (final Object unitDef : unitDefs) { SmooksResourceConfiguration resConfig = (SmooksResourceConfiguration) unitDef; objects.add(applicationContext.getStore().getObject(resConfig)); } } else { objects = EMPTY_LIST; } objectsTable.put(selector, objects); } return objects; }
private void registerInstalledHandlerFactories() { for (Class<ContentHandlerFactory> handlerFactory : handlerFactories) { Resource resourceAnnotation = handlerFactory.getAnnotation(Resource.class); if(resourceAnnotation != null) { addHandlerFactoryConfig(handlerFactory, resourceAnnotation.type()); } } // And add the Java handler... addHandlerFactoryConfig(JavaContentHandlerFactory.class, "class"); }
/** * Close this Smooks instance and all associated resources. * <p/> * Should result in the {@link org.milyn.delivery.annotation.Uninitialize uninitialization} * of all allocated {@link org.milyn.delivery.ContentHandler} instances. */ public void close() { context.getStore().close(); }
public static void removeParameter(String name, Smooks smooks) { SmooksResourceConfigurationStore configStore = smooks.getApplicationContext().getStore(); Iterator<SmooksResourceConfigurationList> configLists = configStore.getSmooksResourceConfigurationLists(); while(configLists.hasNext()) { SmooksResourceConfigurationList list = configLists.next(); for(int i = 0; i < list.size(); i++) { SmooksResourceConfiguration nextConfig = list.get(i); if(ParameterAccessor.GLOBAL_PARAMETERS.equals(nextConfig.getSelector())) { nextConfig.removeParameter(name); } } } } }
/** * Register the set of resources specified in the supplied XML configuration * stream. * @param baseURI The base URI to be associated with the configuration stream. * @param resourceConfigStream XML resource configuration stream. * @return The SmooksResourceConfigurationList created from the added resource configuration. * @throws SAXException Error parsing the resource stream. * @throws IOException Error reading resource stream. * @see SmooksResourceConfiguration */ public SmooksResourceConfigurationList registerResources(String baseURI, InputStream resourceConfigStream) throws SAXException, IOException, URISyntaxException { SmooksResourceConfigurationList configList; if(baseURI == null || baseURI.trim().equals("")) { throw new IllegalArgumentException("null or empty 'name' arg in method call."); } if(resourceConfigStream == null) { throw new IllegalArgumentException("null 'resourceConfigStream' arg in method call."); } configList = XMLConfigDigester.digestConfig(resourceConfigStream, baseURI, applicationContext.getClassLoader()); addSmooksResourceConfigurationList(configList); return configList; }
/** * Add a {@link SmooksResourceConfigurationList} to this store. * * @param resourceList All the SmooksResourceConfigurationList instances added on this store. */ public void addSmooksResourceConfigurationList(SmooksResourceConfigurationList resourceList) { processAppContextInitializers(resourceList); configLists.add(resourceList); // XSD v1.0 added profiles to the resource config. If there were any, add them to the // profile store. addProfileSets(resourceList.getProfiles()); }
public void attachGlobalParameters(ApplicationContext appContext) { if(globalParams == null) { globalParams = appContext.getStore().getGlobalParams(); } }