--- title: "Configurar la función Advanced I/O" url: https://docs.catalyst.zoho.com/es/tutorials/newsapp/java/configure-advancedio/ description: "Construye una aplicación web de noticias que obtiene noticias de un servicio de terceros con Catalyst Cron, y una Job Function y función Advanced I/O en Java." last_updated: 2026-11-04T10:10:44Z service: All Services type: tutorial related_links: - name: "Advanced I/O Function" url: /es/serverless/help/functions/advanced-io - name: "Data Store" url: /es/cloud-scale/help/data-store/introduction - name: "ZCQL" url: /es/cloud-scale/help/zcql/introduction --- # Configurar la función Advanced I/O El directorio de la función Advanced I/O (`functions/NewsApp_AIO`) contiene los siguientes archivos: * El archivo principal de función `DataStoreFetch.java` * El archivo de configuración `catalyst-config.json` * Archivos de biblioteca Java en la carpeta `lib` * Archivos de dependencias `.classpath` y `.project` Agregarás código en el archivo `DatastoreFetch.java`. La función Advanced I/O obtiene el elemento de noticias de su tabla fuente en el Data Store y lo envía al componente client como una respuesta JSON. Copia el código y pégalo en `DatastoreFetch.java ` en el directorio `functions/NewsApp_AIO `. **DatastoreFetch.java** ```java import java.util.logging.Logger; import java.util.ArrayList; import java.util.logging.Level; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.catalyst.advanced.CatalystAdvancedIOHandler; import com.zc.component.object.ZCRowObject; import com.zc.component.zcql.ZCQL; import org.json.JSONArray; import org.json.JSONObject; public class DatastoreFetch implements CatalystAdvancedIOHandler { private static final Logger LOGGER = Logger.getLogger(DatastoreFetch.class.getName()); @Override public void runner(HttpServletRequest request, HttpServletResponse response) throws Exception { try { // Obtener el endpoint y el método HTTP String url = request.getRequestURI(); String method = request.getMethod(); if (url.equals("/fetchData") && method.equals("GET")) { String tableName = request.getParameter("tablename"); // Consultar el Data Store usando ZCQL String query = "select title, url from " + tableName; ArrayList<ZCRowObject> rowList = ZCQL.getInstance().executeQuery(query); JSONObject data = new JSONObject(); JSONArray content = new JSONArray(); // Construir la respuesta JSON for (int i = 0; i < rowList.size(); i++) { JSONObject rowData = new JSONObject(); JSONObject tableData = new JSONObject(); ZCRowObject row = rowList.get(i); String title = (String) row.get("title"); String urlVal = (String) row.get("url"); rowData.put("title", title); rowData.put("url", urlVal); tableData.put(tableName, rowData); content.put(tableData); } data.put("content", content); // Enviar respuesta de vuelta al client response.setContentType("application/json"); response.getWriter().write(data.toString()); response.setStatus(200); } else { // Solicitud inválida LOGGER.log(Level.SEVERE, "Error. Invalid Request"); response.setStatus(404); } } catch (Exception e) { LOGGER.log(Level.SEVERE, "Exception in DatastoreFetch", e); response.setStatus(500); } } } ```