NgModule Properties in Angular 2


NgModule is a decorator function that takes a single metadata object whose properties describe the module. The most important properties are:

declarations – the view classes that belong to this module. Angular has three kinds of view classes: components, directives, and pipes.
exports – the subset of declarations that should be visible and usable in the component templates of other modules.
imports – other modules whose exported classes are needed by component templates declared in this module.
providers – creators of services that this module contributes to the global collection of services; they become accessible in all parts of the app.
bootstrap – the main application view, called the root component, that hosts all other app views. Only the root module should set this bootstrap property.

Source: https://angular.io/

Advertisements
Tagged with: , , , , ,
Posted in Angular

Components of Angular 2


Below are the major  components of Angular 2

Modules − This is used to break up the application into logical pieces of code. Each piece of code or module is designed to perform a single task.

Component − This can be used to bring the modules together.

Templates − This is used to define the views of an Angular JS application.

Metadata − This can be used to add more data to an Angular JS class.

Service − This is used to create components which can be shared across the entire application.

 

Tagged with: ,
Posted in Angular

Angular 2 Features


Angular 2 is a opensource javascript framework developed by developers at google. This framework is used to build the single page applications. Angular 2 has been built by considering the difficulties faced in Angular 1 and Angular 2 removes the obstucles in building single page applications.

Blow are the special features of Angular 2:

Components − Angular 2 is a componenent based framework where as Angular 1 is Controller based framework. Components help to build the applications into many modules. This helps in better maintaining the application over a period of time.

TypeScript − Angular 2 is based on TypeScript(a language for application scale JavaScript development). This is a superset of JavaScript that compiles to clean JavaScript output.

Services − Services are a set of code that can be shared by different components of an application. So for example if you had a data component that picked data from a database, you could have it as a shared service that could be used across multiple applications.

Tagged with: , , , , ,
Posted in Angular

Create Web service using wsgen in command line


Generally bottom up approach, where the service implementation is done first and wsdl will be generated next, is not a suggested way of implementing a web service. In some cases where the service implementation class is already exists in the application and wants to expose it as web service then it is acceptable to go with bottom up approach.

In this post, I would like to show how the web service can be developed in bottom up approach using the wsgen command.

The wsgen tool reads an existing web service implementation class and generates the required JAX–WS portable artifacts for web service development and deployment. The wsgen tool can be used for bottoms-up approach, where you are starting from a service endpoint implementation rather than a wsdl. The generated JAX-WS artifacts can be used by both service and client implementations.

Below is the sample service class created – HellowWorldService.java

package in.malliktalksjava.service;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService(name=”HellowWorldService”,
targetNamespace=”http://malliktalksjava.in”,
wsdlLocation=”http://localhost:8085/HellowWorldService?wsdl”)
public class HellowWorldService{

@WebMethod
public void printHelloMessage(){
System.out.println(“Printing hello message”);
};

@WebMethod
public String getThankyouMessage(){
System.out.println(“Printing thank you message”);

return null;
};

}

Compile the java classes using below command:

javac -d . in/malliktalksjava/service/*.java

Once the compilation is successful, use the below wsgen command to generate the artifacts:

wsgen -verbose -keep -cp . in.malliktalksjava.service.HellowWorldService

Once click on the enter button, below are the artifacts generated in jaxws folder:

in\malliktalksjava\service\jaxws\GetThankyouMessage.java
in\malliktalksjava\service\jaxws\GetThankyouMessageResponse.java
in\malliktalksjava\service\jaxws\PrintHelloMessage.java
in\malliktalksjava\service\jaxws\PrintHelloMessageResponse.java

If it is required to generate the wsdl file along with the artifacts, we need to use the below command:

wsgen -verbose -keep -cp . -wsdl in.malliktalksjava.service.HellowWorldService

Below are the list of options available in wsgen command:

wsgenoptions

 

Tagged with: , , ,
Posted in JAVA

Differences between wsimport and wsgen


wsimport:
The wsimport tool reads a WSDL and generates all the required artifacts for web service development, deployment, and invocation. The wsimport tool supports the top-down approach to developing JAX-WS Web services, where you are starting from a wsdl.
The wsimport tool generated JAX-WS portable artifacts include Service Endpoint Interface (SEI), Service, Exception class mapped from wsdl:fault (if any), JAXB generated value types (mapped java classes from schema types) etc. These artifacts can be packaged in a WAR file with the WSDL and schema documents along with the endpoint implementation to be deployed.

Ex Command : wsimport http://localhost:8090/MyJaxWSService?wsdl

wsgen:
The wsgen tool reads an existing web service implementation class and generates the required JAX–WS portable artifacts for web service development and deployment. The wsgen tool can be used for bottoms-up approach, where you are starting from a service endpoint implementation rather than a wsdl.

Ex Command : wsgen -verbose -keep -cp . in.malliktalksjava.service.HellowWorldService

 

wsgen and wsimport generate request and response wrapper bean classes and the JAXB classes. However, wsgen generates the JAXB classes and put them in a jaxws folder. But wsimport does not put those classes in any folder instead in the current directory.

The JAX-WS artifacts generated can be used by both service implementation and client implementation.

Using wsgen you can also generate the wsdl using based on webservice implementation class.

Tagged with: , , , , , , ,
Posted in JAVA, Web Services

Create web service in Bottom Up approach using command line


Create Service Interface MyJaxWSSEI.java

package in.malliktalksjava.ws;

import in.malliktalksjava.ws.pojo.*;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.WebParam.Mode;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.jws.soap.SOAPBinding.Use;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;

@WebService(name = “MyJaxWSHello”,
targetNamespace = “http://malliktalksjava.in”,
wsdlLocation = “http://malliktalksjava.in/MyJaxWS?wsdl”)
@SOAPBinding(style=Style.RPC, use=Use.LITERAL)
public interface MyJaxWSSEI {

@WebMethod(operationName=”getJXWsRes”)
@RequestWrapper(targetNamespace=”http://malliktalksjava.in/ws/types”,
className=”java.lang.String”)
@ResponseWrapper(targetNamespace=”http://malliktalksjava.in/ws/types”,
className=”in.malliktalksjava.ws.JXRes”)
@WebResult(targetNamespace=”http://malliktalksjava.in/ws/types”,
name=”JXWsRes”)
public JXRes getJXWsRes(
@WebParam(targetNamespace=”http://malliktalksjava.in/ws/types”,
name=”name”,
mode=Mode.IN)
String name
);

}

 

Create Implementation class for the above interface – MyJaxWSSEIImpl.java

package in.malliktalksjava.ws;

import in.malliktalksjava.ws.pojo.*;
import javax.jws.WebService;

@WebService(endpointInterface=”in.malliktalksjava.ws.MyJaxWSSEI”,
targetNamespace=”http://malliktalksjava.in”,
portName=”MyJaxWSSEIPort”,
serviceName=”MyJaxWSHelloService”)
public class MyJaxWSSEIImpl implements MyJaxWSSEI {

/**
* Default Constructor
*/
public MyJaxWSSEIImpl() {

}

/* (non-Javadoc)
* @see in.malliktalksjava.ws.MyJaxWSSEI#getJXWsRes(java.lang.String)
*/
@Override
public JXRes getJXWsRes(String name) {
JXRes jxRes = new JXRes();
jxRes.setMessage(“Hello”);
jxRes.setName(name);
return jxRes;
}

}

Create Required Model object JXRes.java

package in.malliktalksjava.ws.pojo;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class JXRes {
protected String message;
protected String name;
/**
*
*/
public JXRes() {
super();
}
/**
* @return the id
*/
public String getMessage() {
return message;
}
/**
* @param id the id to set
*/
public void setMessage(String message) {
this.message = message;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}

}

Create Main Class JXResTest.java

package in.malliktalksjava.ws.main;

import javax.xml.ws.Endpoint;
import in.malliktalksjava.ws.*;

public class JXResTest {
public static void main(String[] args ){
Endpoint.publish(“http://localhost:8080/MyJaxWSService”, new MyJaxWSSEIImpl());
}
}

 

Compile Java Classes in command prompt:

compileclass

Run the class

runmainclass

Verify the service : http://localhost:8080/MyJaxWSService?wsdl

wsdl

 

Tagged with: , , ,
Posted in JAVA, Web Services

Spring Security Namespace Designs


The namespace is designed to capture the most common uses of the framework and provide a simplified and concise syntax for enabling them within an application. The design is based around the large-scale dependencies within the framework, and can be divided up into the following areas:

  • Web/HTTP Security – the most complex part. Sets up the filters and related service beans used to apply the framework authentication mechanisms, to secure URLs, render login and error pages and much more.
  • Business Object (Method) Security – options for securing the service layer.
  • AuthenticationManager – handles authentication requests from other parts of the framework.
  • AccessDecisionManager – provides access decisions for web and method security. A default one will be registered, but you can also choose to use a custom one, declared using normal Spring bean syntax.
  • AuthenticationProviders – mechanisms against which the authentication manager authenticates users. The namespace provides supports for several standard options and also a means of adding custom beans declared using a traditional syntax.
  • UserDetailsService – closely related to authentication providers, but often also required by other beans.
Tagged with: , , , , , ,
Posted in Spring, Spring Security

SOAP Vs REST Web Services


SOAP REST
1) SOAP is a protocol. REST is an architectural style.
2) SOAP stands for Simple Object Access Protocol. REST stands for REpresentational State Transfer.
3) SOAP can’t use REST because it is a protocol. REST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP.
4) SOAP uses services interfaces to expose the business logic. REST uses URI to expose business logic.
5) JAX-WS is the java API for SOAP web services. JAX-RS is the java API for RESTful web services.
6) SOAP defines standards to be strictly followed. REST does not define too much standards like SOAP.
7) SOAP requires more bandwidth and resource than REST. REST requires less bandwidth and resource than SOAP.
8) SOAP defines its own security. RESTful web services inherits security measures from the underlying transport.
9) SOAP permits XML data format only. REST permits different data format such as Plain text, HTML, XML, JSON etc.
10) SOAP heavy weight operation. REST is light weight and suggested to use in lower band with scenarios such as accessing applications using mobile devices.
11) SOAP is less preferred than REST. REST more preferred than SOAP.
Tagged with: , , , , ,
Posted in Web Services

Features of Spring Web MVC


Spring’s web module includes many unique web support features:

  • Clear separation of roles. Each role—controller, validator, command object, form object, model object, DispatcherServlet, handler mapping, view resolver, and so on—can be fulfilled by a specialized object.
  • Powerful and straightforward configuration of both framework and application classes as JavaBeans. This configuration capability includes easy referencing across contexts, such as from web controllers to business objects and validators.
  • Adaptability, non-intrusiveness, and flexibility. Define any controller method signature you need, possibly using one of the parameter annotations (such as @RequestParam, @RequestHeader, @PathVariable, and more) for a given scenario.
  • Reusable business code, no need for duplication. Use existing business objects as command or form objects instead of mirroring them to extend a particular framework base class.
  • Customizable binding and validation. Type mismatches as application-level validation errors that keep the offending value, localized date and number binding, and so on instead of String-only form objects with manual parsing and conversion to business objects.
  • Customizable handler mapping and view resolution. Handler mapping and view resolution strategies range from simple URL-based configuration, to sophisticated, purpose-built resolution strategies. Spring is more flexible than web MVC frameworks that mandate a particular technique.
  • Flexible model transfer. Model transfer with a name/value Map supports easy integration with any view technology.
  • Customizable locale, time zone and theme resolution, support for JSPs with or without Spring tag library, support for JSTL, support for Velocity without the need for extra bridges, and so on.
  • A simple yet powerful JSP tag library known as the Spring tag library that provides support for features such as data binding and themes. The custom tags allow for maximum flexibility in terms of markup code.
  • A JSP form tag library, introduced in Spring 2.0, that makes writing forms in JSP pages much easier.
  • Beans whose lifecycle is scoped to the current HTTP request or HTTP Session. This is not a specific feature of Spring MVC itself, but rather of the WebApplicationContext container(s) that Spring MVC uses.
Tagged with: , , , , , , ,
Posted in Spring

Introduction to Apache Cordova


Apache Cordova is a platform for building native mobile applications using HTML, CSS and JavaScript. It is a set of device APIs that allow a mobile app developer to access native device function such as the camera or accelerometer from JavaScript. Combined with a UI framework such as jQuery Mobile or Dojo Mobile or Sencha Touch, this allows a smartphone app to be developed with just HTML, CSS, and JavaScript.

When using the Cordova APIs, an app can be built without any native code (Java, Objective-C, etc) from the app developer. Instead, web technologies are used, and they are hosted in the app itself locally (generally not on a remote http server).

And because these JavaScript APIs are consistent across multiple device platforms and built on web standards, the app should be portable to other device platforms with minimal to no changes.

Apps using Cordova are still packaged as apps using the platform SDKs, and can be made available for installation from each device’s app store.

Cordova provides a set of uniform JavaScript libraries that can be invoked, with device-specific native backing code for those JavaScript libraries. Cordova is available for the following platforms: iOS, Android, Blackberry, Windows Phone, Palm WebOS, Bada, and Symbian.

Content Source: https://cordova.apache.org/

Tagged with: , , , , , , , , ,
Posted in Apache Cordova, Mobile Platforms

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 677 other followers

Calendar
December 2017
M T W T F S S
« Aug    
 123
45678910
11121314151617
18192021222324
25262728293031
Mallikarjun Gunda

This is Mallikarjun Gunda, I am working as a software professional. Blogging is my Passion. This blog contains the posts on Java related technologies and programming languages. I am happy to share my knowledge through the blogs.

Blog Stats
  • 237,353 hits
IndiBlogger
malliktalksjava.wordpress.c...
70/100
All tags
AngularJS Apache Cassandra Arrays in Java Cassandra Cassandra Database Cassandra examples client stubs creating a java web service creating a web service using java difference between interface and abstract class Differences between SOAP and RESTfull webservices Display div as Overlay using JQuery download the spring basic application File directory Generating webservice client stubs Hibernate hibernate exceptions How to display over using JQuery how to generated web service client stubs in STS How to implement Spring basic application how to write singleton design pattern in java interface in java Java Java Arrays Java Example Programs Java examples Java interview questions java programs java project Java sample Programs Java Script JavaScript JavaServer Faces Java Sorting alogorithms Java Tutorials javatutorials Java Web services JDBC open shift openshift Overlay implementation using JQuery Overlay in JQuery POI API POI Examples public class public static void main Redhat OpenShift representational state transfer Restfull webservices sample programs in java Service-oriented architecture Singleton design pattern in java SOAP SOAP Webservices software Spring Framework Spring Interview Questions Spring MVC Spring MVC Example program Spring MVC sample Program Spring Sample Programs Spring Tutorials Struts technology Top Java Interview questions w3c dom Web service web service client Web Service Description Language webservices Web services writing singleton design pattern in Java WSDL Xml xml parsers