Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

Wednesday, October 21, 2015

Developing against Oracle Mobile Cloud Service (MCS) with Oracle Enterprise Pack for Eclipse (OEPE) and the Mobile Application Framework (MAF)

If you want to get started developing against the Oracle Mobile Cloud Service (MCS) using the Oracle Enterprise Pack for Eclipse (OEPE) and the Mobile Application Framework (MAF) here is a quick demonstration for you to get a feel and see how quick you can get things done.

In the following 5 min. demonstration you'll see how to setup a new MAF application, connect to the Oracle Cloud from Eclipse, search for the mobile backend you're interested on, import the API definition to your app, generate the required data controls, populate a new page with data and deploy to the Android emulator.

Have fun!



Monday, October 12, 2015

Getting Started with Oracle Enterprise Pack for Eclipse and Mobile Cloud Service APIs

There is a recent uploaded Oracle Mobile Cloud Service (MCS) tutorial that walks you through the process of connecting Oracle Enterprise Pack for Eclipse (OEPE) to the MCS APIs.

There are 6 steps involved on this tutorial and you will:
  • Start Eclipse and configure it to work with Oracle Mobile Application Framework (MAF)
  • Create a new mobile application, a new feature and a page to hold data
  • Connect the MAF-based application to an MCS instance
  • Generate the Java classes to support the exposed MCS REST API
  • Develop a new page by adding data and security settings
  • Package, deploy and test the application

Enjoy!



Friday, October 21, 2011

Using Apache Camel for Application Notification

I was watching a forum thread (http://fusesource.com/forums/thread.jspa?threadID=3433) this week where the use case was not to consume the file content but rather the file name. That seems to be an interesting use of Apache Camel because most of people used the Camel File Component to consume the contents of the file and then do some kind of processing on top of that (routing, web services invocation, ftp, bean execution, database interaction, etc).

What brought my attention to this specific use case is that the important information here was the file name and not the content of the file. Given that the file itself was pretty large (around ~1GB) it would be a nightmare to handle all of that in memory on a Camel route or any other middleware available out there. But, this use case is really about notifying other systems or applications that a large file is available to be processed outside the route (think about a file being available for download for example) and the reason to only care about the file name is that information could be part of the URL generated during the processing of the Camel route.

So, basically the Camel route was watching the file system for files generated, then grabbed the file name and then notify another system or application (or even the end user i.e. e-mail) that the file was ready to be consumed. I've recreated below the Camel route generated by default in the sample project to illustrate how to do that.


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
    <camel:package>com.fusesource.fusebyexample</camel:package>
 <camel:route>
      <!-- Consume Files from the File System -->
      <camel:from uri="file:src/data/?noop=true"/>
      <!-- Set the Message Payload with the File Name --> 
      <camel:setBody>
          <camel:simple>header.CamelFileName</camel:simple>
      </camel:setBody>
      <camel:log message="The message contains ${body}"/>
      <!-- Perform simple Content-Based Routing -->
      <camel:choice>
      <camel:when>
          <camel:simple>${body} == 'message1.xml'</camel:simple>
          <camel:log message="Going to UK message"/>
          <camel:to uri="file:target/messages/uk"/>
        </camel:when>
        <camel:otherwise>
          <camel:log message="Going to Other message"/>
          <camel:to uri="file:target/messages/others"/>
        </camel:otherwise>
      </camel:choice>
    </camel:route>
  </camel:camelContext>
</beans>


Of course, if you want to try that out, the project is available at: https://github.com/mjabali/FileNameBasedRouter

Enjoy the ride!

Thursday, August 4, 2011

New Fuse IDE 2.0 Release


Now at version 2.0, the Fuse IDE (an Eclipse plugin) builds on a visual environment that enables developers to "drag-and-drop" the integration and mediation components needed to connect several systems and applications. I'd like to give you some highlights of this very exciting release.

Additionally to the already known features (http://fusesource.com/collateral/112/), here is what's included:

  • Endpoint browsing – which makes it easy to see and inspect the available messages on endpoints or JMS  queues

  • Message drag and drop – from an endpoint or JMS queue to any Camel endpoint or JMS destination to quickly try out integration scenarios
  • JMX explorer – tailored to view Fuse integration applications

  • Graphical viewer – displays all brokers, queues, topics, Camel endpoints, and Camel routes available in a remote JVM

  • Route tracing – step through each version of each message to see how message headers and bodies change as they move through routes

So, don't wait to try out these new features... download the new Fuse IDE, provide feedback and we can make it even better!

Enjoy the ride!

Friday, July 8, 2011

Calling Web Services with Apache Camel

Web Services are very important components of most (if not all) of the integration projects these days. The Web Services architecture make them extremely useful for distributed applications and they are often associated with Service-Oriented Architecture (SOA).

Calling Web Services from Apache Camel is pretty simple yet powerful and Camel uses Apache CXF (http://cxf.apache.org).

Apache CXF provides you many options to build Web Services (JAX-WS Annotated Services from Java, JAX-WS Annotated Services from WSDL, JAX-WS Providers, Simple Frontend and JavaScript).
Additionally, there are three major types of services (SOAP, REST and CORBA). For more information, check this web page http://cxf.apache.org/docs/how-do-i-develop-a-service.html.

JAX-WS (Java API for XML Web Services) specification defines annotations that allow you to tell CXF how your POJOs should be represented on the web.

Basically, there two types of web services development with Apache CXF:

Contract-first development - Recall that WSDLs define what operation and types a web service provides. This is often referred to as web services contract, and in order to communicate with a web service, you must satisfy the contract. Contract-first development means that you develop a WSDL file and then generate stub Java class implementations using a tool like Apache CXF.

Code-first development - The other way to develop web services is by starting out with a Java class and then letting the web service framework handle the job of generating a WSDL contract for you. In this case, Apache CXF will be in control of what the contract will be.

To configure the CXF component URI in Camel there are two main ways that you can do that:

Configuring Using the URI Options - The most simple way (and the one will be using for demo purposes) where you pass inline parameters to the component. Here is the format you have to specify:

cxf://<service_address>[?options]

The options available for the CXF component are available here: http://camel.apache.org/cxf.html

Referencing a Bean - Using this approach, you have to specify a bean containing the configuration. You have much more power and flexibility than configuring CXF via URI options but it also requires more work on your side. You can configure things like CXF interceptors, JAX-WS handlers and the CXF bus but we're going to cover that on a different blog post. To configure the CXF component referencing a bean the URI is something like this:

cxf:bean:beanName where the beanName specifies the ID of the CXF endpoint bean defined in your Spring XML file.

So, to give you a taste of what's going to be a simple project calling Web Services with Apache Camel here is the step-by-step procedure:

I'll be using the FuseIDE for that but the artifacts generated are pretty much the same if you choose the Maven approach.

Here is what you need:

- Eclipse IDE (Eclipse Helios 3.6.2)
- Apache Maven (3.0.3)
- FuseSource Camel IDE (http://fusesource.com/products/fuse-ide-camel/)


Then, create a new Fuse IDE project and select the Camel Archetype and type the Group Id, Artifact Id and Package name for your project then click Finish.


As I've explained before on my previous post (http://marcelojabali.blogspot.com/2011/06/file-batch-splitter-with-apache-camel.html) the default Fuse IDE project comes with a sample configuration that you can remove for the purpose of this demonstration.


Create a new Camel XML File (camelContext.xml) and then create a new route. 


Drag and drop an endpoint from the palette and also a log component. Connect them and make sure you save your project. You should see something like the picture below:




Edit the URI property of the Endpoint to be: file:src/data?noop=true


Edit the Message property of the Log component to be: ${body} and the Logging Level to INFO


You should be able to run this route now which is going to display the content of files under the src/data directory in your project in the Camel log. It's always a good practice to make sure every step in your route runs consistently and without any problems.


To run the Camel route (if you're using the FuseIDE) just right click int the Camel XML file and then select Run As... Local Camel Context.


If everything executed correctly you should see the content of the files in the Eclipse console and you're ready for the next step.


Add another Endpoint to your route. Connect the Log component to the new created Endpoint.

The recently added Endpoint is going to be our CXF component. We're going to use a sample Stock Quote Web Service available at http://www.webservicex.net/WS/WSDetails.aspx?CATID=2&WSID=9

Click on the Endpoint and then add the following to the URI:

cxf://http://www.webservicex.net/stockquote.asmx?wsdlURL=src/main/resources/META-INF/stockquote.wsdl&serviceName={http://www.webserviceX.NET/}StockQuote&portName={http://www.webserviceX.NET/}StockQuoteSoap&dataFormat=MESSAGE

Here are the options being used on this simple call:

cxf://http://www.webservicex.net/stockquote.asmx - Endpoint definition (cxf) and then the required service address

wsdlURL=src/main/resources/META-INF/stockquote.wsdl - The location of the WSDL file

serviceName={http://www.webserviceX.NET/}StockQuote - The service name this service is implementing, it maps to wsdl:service@name

portName={http://www.webserviceX.NET/}StockQuoteSoap - The port name this service is implementing, it maps to wsdl:port@name

dataFormat=MESSAGE - The data type messages supported by the CXF endpoint (default is POJO)


The last step in the route to be implemented is a Log component to display the Web Service response. To do that, just add another Log and connect the CXF component to it.


Edit the Message property of the Log component to be: ${body} and the Logging Level to INFO


Your route should be similar to the following:




Save the project.


For reference, here is the whole route:




<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:cxf="http://camel.apache.org/schema/cxf" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.springframework.org/schema/beans  
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://camel.apache.org/schema/spring
    http://camel.apache.org/schema/spring/camel-spring.xsd">

  <camelContext xmlns="http://camel.apache.org/schema/spring" trace="false">
    <route id="my_Sample_Camel_Route_with_CXF">
        <from uri="file:src/data?noop=true"/>
        <log loggingLevel="INFO" message="&gt;&gt;&gt; ${body}"/>
        <to uri="cxf://http://www.webservicex.net/stockquote.asmx?
        wsdlURL=src/main/resources/META-INF/stockquote.wsdl&amp;
        serviceName={http://www.webserviceX.NET/}StockQuote&amp;
        portName={http://www.webserviceX.NET/}StockQuoteSoap&amp;
        dataFormat=MESSAGE"/>
        <log loggingLevel="INFO" message="&gt;&gt;&gt; ${body}"/>
    </route>
</camelContext>

</beans>




Before you test it make sure you change the values of the sample messages (under src/data) to the following:


message1.xml:


<?xml version="1.0" encoding="utf-8"?>


<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetQuote xmlns="http://www.webserviceX.NET/">
      <symbol>AAPL</symbol>
    </GetQuote>
  </soap12:Body>
</soap12:Envelope>

message2.xml:

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetQuote xmlns="http://www.webserviceX.NET/">
      <symbol>GOOG</symbol>
    </GetQuote>
  </soap12:Body>
</soap12:Envelope>

This is the SOAP format that the web service is expecting and we're not doing any message transformation here so far.
At this point, you're ready to go and you just need to run the Camel route as explained before.
After you run the route, you should see two messages being displayed in the Eclipse console with the content of the files you just edited and then two responses from the Web Service showing the stock value of AAPL and GOOG.

The sample code is available at https://github.com/mjabali/CXF-Sample

Enjoy the ride!






Wednesday, June 8, 2011

File Batch Splitter with Apache Camel and FuseSource Camel IDE

The Splitter from the EIP patterns allows you split a message into a number of pieces and process them individually.

To implement that EIP pattern using Apache Camel and FuseSource Camel IDE is very simple. Here is what you need:

1) Eclipse IDE (Eclipse Helios 3.6.2)
2) Apache Maven (3.0.3)
3) FuseSource Camel IDE (http://fusesource.com/products/fuse-ide-camel/)

After you install and configure the tools mentioned above, start creating a new Fuse IDE Project.


Select the Camel Archetype and type the Group Id, Artifact Id and Package name for your project then click Finish:


At this point you should have a sample Camel project and artifacts available for you. The default Camel project gives you another EIP, the Content-Based Router (http://camel.apache.org/content-based-router.html). You can open the camelContext.xml under the META-INF/spring directory and remove the Camel components available there since we're going to implement a different EIP (right-click and then Delete).

To start creating the File Batch Splitter sample project, right-click in the canvas of the camelContext.xml file and select Add > Route. We're now ready to start building our process. Right-click inside the Route rectangle and select Add > Endpoints > Endpoint.

Then, right-click again and select Add > Routing > Split. Finally, right-click and select Add > Endpoints > Endpoint. Now, click on the first created Endpoint and draw a line to the Split component. Do the same thing between the Split component and the second Endpoint.

You can also click on the Automatic Layout icon available in the Eclipse top menu bar to automatically adjust your route diagram.

Now, you have added all necessary components and should have something similar to the following picture.



You can now configure each component to execute the tasks needed to conclude the File Batch Splitter sample project. Basically, we'll consume files from one directory in the file system (an XML file with multiple records), split each record in the XML file into a new file in the file system.

To do that, click on the first endpoint and go to the Properties tab where you can see the details of each component. In the Uri field, type: file:src/data?noop=true


Highlight the Split component and type the condition you want to generate new records from the input file. In this case, we're going to use the following: //club/person as a XPath expression.



And then, highlight the final endpoint and type the following in the Uri field: file:target/output?fileName=${date:now:yyyyMMddHHmmssSSSSS}.xml
We're using a dynamic file name based on the current date to avoid conflicts and/or overriding the original files. So, every record gets a new file name when Camel creates the file.



Before we execute our Camel project, we need an input file under the src/data directory. Here is the content of a sample file to use:


<?xml version="1.0" encoding="UTF-8"?>
<club>

    <person user="marcelo">
        <firstName>Marcelo</firstName>
        <lastName>Jabali</lastName>
        <city>San Diego</city>
    </person>
    <person user="scott">
        <firstName>Scott</firstName>
        <lastName>Cranton</lastName>
        <city>Boston</city>
    </person>
</club>


The step before we execute the project is to configure how to run it. There are a couple different ways to run it but basically you can configure everything in Eclipse. Just go to Run > Run Configurations and then under Local Camel Context you can create a new configuration just pointing to the camel-Context.xml file. Click Apply and then Run.

If everything was configured correctly you should be able to see two XML files under the src/output directory containing a person record each (don't forget to refresh the view).

You also have the option to execute that project through Maven on the command line. Just navigate to the root directory of the project and type:

>mvn camel:run



That does the same thing that we executed under the Eclipse IDE.

If you want to download the files and play with the samples the project files are available on GitHub (https://github.com/FuseByExample/FileBatchSplitter)

Enjoy the ride...

Friday, March 18, 2011

Desktop Events with OpenSpan and Oracle CEP - Part 1

Oracle’s Complex Event Processing Engine can be used to monitor large volumes of real-time data feeds but how do you enable your existing applications to trigger and react with the CEP engine?

With OpenSpan Events you can quickly and easily monitor any application or set of applications on a user’s desktop - including Windows, Web, Java, mainframe, cloud-based, virtualized or Citrix-hosted applications - without modifying the original applications. All events and associated data can be sent in real-time to Oracle CEP, as well as stored in an Oracle or other central database for analysis using OpenSpan Analytics, Oracle Hyperion or any other BI or reporting tool.

Here is a step-by-step guide to get you started with OpenSpan Events with Complex Event Processing (CEP) technology. Part 1 of this tutorial is going to cover Oracle WebLogic JMS setup.

1. Download and Install Oracle WebLogic 11g R1 (http://www.oracle.com/technetwork/middleware/weblogic/downloads/index.html)

2. Download and Install Oracle Complex Event Processing 11gR1 (http://www.oracle.com/technetwork/middleware/complex-event-processing/downloads/index.html)

3. Configure Oracle CEP plugin on Eclipse Galileo shipped with Oracle WebLogic 11g R1 (http://download.oracle.com/docs/cd/E14571_01/doc.1111/e14301/ide_intro.htm#CHDGBGGA)

4. Start your Oracle WebLogic instance (Start Menu > Programs > Oracle WebLogic > User Projects > base_domain > Start Admin Server for WebLogic Server Domain). Wait for the confirmation the server is up and running. You should see a message on the log similar to the following:

<mar 18, 2011 2:58:30 PM EDT> <notice> <weblogicserver> <BEA-000360> <server started in RUNNING mode>

5. Log in to WebLogic Server 11g Administration Console pointing your web browser to http://localhost:7001/console.

6. Click on JMS Modules under Services > Messaging. By default, Oracle WebLogic creates a JMS Module called SystemModule-0. If you don’t have it, you’ll have to create one. Click on SystemModule-0.

7. You also have to create new Queues for the sample configuration where the message exchange between the desktop applications and the Oracle CEP server is going to happen. Click on New and then select Queue. Click Next and give it a name of osevents_SampleQ1. Click Finish. Repeat the process to create another Queue called osevents_SampleQ2.
You also have to create a new connection factory object that's used to create connections for JMS clients. Name your new connection factory object osevents_queue_cf with the same JNDI name.

8. To test your recently created configuration you may want to configure a few JMS clients to send and receive messages to/from these queues. I'd recommend you taking a look on the bottom of the following resource for a pretty nice and straightforward client configuration available at http://redstack.wordpress.com/2009/12/21/a-simple-jms-client-for-weblogic-11g/.

Setting Up Local Environment for Developing Oracle Intelligent Bots Custom Components

Oh the joy of having a local development environment is priceless. For most cloud based solutions the story repeats itself being hard to tr...