Creating and deploying an SCA application IBM® WebSphere® Application Server V7 Feature Pack for Service Component Architecture Creating and deploying an SCA application –simple SCA application This presentation will show you how to create and deploy a simple SCA application. Creating and deploying a sample SCA application Creating and deploying a sample SCA application Section This next section discusses how you go about creating and deploying a simple SCA application. SCA application packaging SCA application packaging The POJO JAR package The composite definition The Java™ implementation with annotations // This is the service interface package services.hello; @Remotable public interface HelloService { String hello(String message); } // This is the service implementation package services.hello; import org.osoa.sca.annotations.*; @Service(HelloService.class) public class HelloServiceImpl implements HelloService { public String hello(String message) { ... }} First, look at the packaging to see where things go before creating an application. Take a look at the POJO JAR package on the top left side. As you can see, when you create a simple service interface class with its implementation class, these classes will go under a package. The default.scdl goes under the META-INF directory and, of course, if there was a wsdl involved, it goes under the WEB-INF directory. The composite files would go in the sca-deployables directory. Also on that picture you can see a sample composite definition, the interface class and the implementation class. Note the use of the @service annotation that was discussed earlier and the @Remotable. As a re-cap, the @Remotable annotation on a Java interface indicates that the interface is designed to be used for remote communication. Remotable interfaces are intended to be used for coarse grained services. Operations parameters and return values are passed by-value. Note that the SCA Packaging model is not dependent on JEE JAR, zip, or WAR files; therefore it can be deployed directly into WebSphere Application Server. Creating an SCA application (service provider) Creating an SCA application (service provider) Create service interface and service implementation and compile Create the composite file (META-INF/sca-deployables) Optional: Create sca-contribution.xml (META-INF) Create a jar file: service interface implementation classes the composite file the sca-contribution.xml file Jar Optional sca-contribution.xml class interface Service .composite Import jar Asset Create BLA and CU Add asset BLA Asset BLA 1 2 3 4 1 2 3 Deploying an SCA application in WebSphere This picture is a summary of the steps needed to create and deploy an SCA application. Under creating an SCA application, you can see the implementation classes, the composite file, contribution file and the .jar file. Under deployment, you can see the asset, business level application and the asset added into the business level application. Each of these steps is discussed in the next couple of slides. Building an SCA application with default binding (1) Building an SCA application with default binding (1) Build the service interface class Example: HelloWorldService.java Build the service implementation class Example: HelloWorldServiceImpl.java Compile these classes Create a composite file (.composite – example HelloWorldService.composite) to declare the sca composite, components and services place this composite file under META-INF/sca-deployables directory 1 2 Now that you have seen the general structure of how files are laid out in SCA, the next step is to create a simple SCA application step by step. The first step is to create the Java classes, the service interface classes and the service implementation classes, and then compile them. In general, a best practice for application development is to start with WSDL as the interface, run wsimport to generate the Java interface. After that you can write the implementation from the generated Java interface and the generated JAXB objects. Once you have created your Java classes, the next step is to create a composite file to declare the SCA composite, components, and services. The name of the composite file and the directory where it is stored does not matter if you plan on creating the sca-contribution.xml file as explained later. Otherwise you need to place this composite file under META-INF/sca-deployables directory. Sample HelloWorldService.composite Sample HelloWorldService.composite Here is a sample composite file and what it looks like. Note the specified namespace and the component name. Building an SCA application with default binding (2) Building an SCA application with default binding (2) OPTIONAL: Create the sca-contribution.xml under META-INF directory Sample sca-contribution.xml Create a jar containing: service interface implementation classes composite file sca-contribution.xml file 3 4 The third step is creating the sca-contribution.xml file under the META-INF directory. It is optional to create this file if the composite file is created in the sca_deployables directory. You can have composites anywhere in the system, and you can use a contribution file to declare the deployable composites. If you create a contribution file, make sure that the namespace under which the deployable composite is declared is the target namespace defined for that composite in its composite file. In the example shown, HelloWorldService composite is declared under the namespace http://foo, which is the target namespace for that composite declared in the HelloWorldService.composite. The final step is to create a jar containing service interface and implementation classes, the composite file and the sca-contribution.xml file. This becomes your server side SCA application. Now that an application has been created, you will see how you run and look at it. Building war file (side step) Building war file (side step) Client side On the client side, create a WAR file with a JSP to locate the helloworld service Sample of what is in the JSP Install the WAR into the administrative console On the client side of things, you need to create a WAR file with a simple JSP to locate the HelloWorld Service. This step can be done anytime during the creation or deployment of an SCA application. The example on the slide shows what is inside the JSP. Note the context.getService to locate the HelloWorld Service. Note that context.getService is not supported on the Web services binding. Once you have the WAR file in place, you are now ready to deploy the application. You can install the WAR file through the administrative console just like any JEE application. Deploying an application Deploying an application Section This section will show you how you deploy an SCA application using the administrative console. Applications as compositions - BLA Applications as compositions - BLA Application SCA application Web module DB2® database Library Enterprise application Configuration Composition Application Application Business logic assets .Net service SCA contribution Java library WAR EAR In the administrative console, there is the concept of business level applications. A business level application, or BLA, is a WebSphere configuration artifact that has these characteristics: 1) It captures the entire definition of an enterprise level application consisting of WebSphere Application Server, though it may not explicitly manage the life cycle of every constituent part of its definition. It is a composition model for defining an application. 2) It does not represent or contain the application binaries. This provides a clean separation between the administration of binaries versus the administration of the application definition. 3) It also supports recursive composition. The composition at its lowest level consists of configured instances of application binaries that are configured to run in a specific runtime environment such as WebSphere Application Server. The above three-tier diagram shows the composition model for a business level application. At the bottom are the assets such as the JAR files, WAR files, EAR files and so on and the SCA contribution and the SCA WAR file. The next level up is the composition units. The composition units are the deployed assets such as the EJB modules, Web modules, Web service modules and so on. This level also contains the SCA application. At the top level are the Business-level applications. As an example, you can take an EAR file (an asset) and install it into WebSphere. This EAR file gets saved in the WebSphere repository as a composition unit, or CU. This CU can then get added to a BLA. SCA contribution – Import asset SCA contribution – Import asset 1 Import asset Now to continue with the deployment of the SCA application that was created a couple of slides earlier. If the jar you created is called exa1.jar, that JAR file needs to be imported as an asset. That is done in the administrative console through the menu option, Applications->ApplicationTypes->Assets and then select “Import.” Administrative console experience - BLAs Administrative console experience - BLAs 2 Create a business level application 2 2 2 Next you create a business level application from the menu Applications->Application Types->Business level Applications. Administrative console experience – SCA composite Administrative console experience – SCA composite Add asset to the business level application 3 3 Next you add the asset under the BLA, which will create the SCA composite components. From the picture, note the SCA composite component created. You can also install the war file from the administrative console so that the service is seen. Once that is done, you are ready to start the SCA application. This concludes the SCA application creation and deployment process. Bear in mind that this is a very simple case of creating an SCA application. Many other things can come into play like the quality of service when creating SCA applications. For example, you could add authorization policies to composites and configure user roles on the administrative console during deployment. Other presentations look at security and authorization as quality of services. The next three slides show you a quick snapshot of some of the things you might configure on an SCA application. Administrative console: Intents Administrative console: Intents As an example, from the administrative console, intents can be specified for your application optionally when adding assets with policy set defined to business level applications. Security policy example – Map to policySet Security policy example – Map to policySet Attach policyset This example shows how the intent is mapped to the policy set on the administrative console using the “Attach” button. Security policy example – Service providers Security policy example – Service providers You can also see from the service providers the policy set that got attached to the service component. Creating an SCA application (service provider) Creating an SCA application (service provider) Creat Service interface and service implementation and compile Create the composite file (META-INF/sca-deployables) Optional: Create sca-contribution.xml (META-INF) Create a jar file: service interface implementation classes the composite file the sca-contribution.xml file Jar Optional sca-contribution.xml class interface Service .composite Import Jar Asset Create BLA and CU Add asset BLA Asset BLA 1 2 3 4 1 2 3 Deploying an SCA application in WebSphere Recap! Recap! Recap! Recap! To summarize the steps one more time: Under creating an SCA application, you create the implementation classes, the composite file, contribution file and the jar. Under Deployment, you import the .jar file as an asset, create a business level application, and add the asset into the business level application. Summary Summary Section In summary, this presentation looked at the creation and deployment of an SCA application. Summary Summary SCA feature pack has implemented the discussed scenarios which will help you understand the features in SCA feature pack The shipped samples are a good start at looking at these features in preparation for creating your own SCA applications The SCA feature pack allows you to choose from three different development approaches. A good starting point to learn about your options is with the samples that are provided with the product. Feedback Feedback Your feedback is valuable You can help improve the quality of IBM Education Assistant content to better meet your needs by providing feedback. Did you find this module useful? Did it help you solve a problem or answer a question? Do you have suggestions for improvements? Click to send e-mail feedback: mailto:iea@us.ibm.com?subject=Feedback_about_WASv7SCA_CreatingSCApp_createDeployApp.ppt This module is also available in PDF format at: ../WASv7SCA_CreatingSCApp_createDeployApp.pdf You can help improve the quality of IBM Education Assistant content by providing feedback. Trademarks