DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Latest Articles - DZone

article thumbnail
Build and Release Scala/Java Gradle Project in GitLab Using Jenkins to Artifactory
Looking to learn about building a Scala/Java Gradle project in GitLab? Here's how to do so with Jenkins.
September 23, 2015
by Rado Buranský
· 14,133 Views · 3 Likes
article thumbnail
Multiplexing: TCP vs HTTP2
And now the question you've all been waiting for: can you use TCP AND HTTP2? Read on...
September 23, 2015
by Lori MacVittie
· 9,102 Views · 5 Likes
article thumbnail
How To Create a Bitmap Blur Effect In Android Using RenderScript
Learn how to achieve the popular blur effect on your Android apps
September 23, 2015
by Nilanchala Panigrahy
· 14,839 Views · 3 Likes
article thumbnail
Test APIs in FitNesse - Part 1
A tutorial on how to use the open source FitNesse testing tool to create a simple test API.
September 23, 2015
by Aniruddha Ranjekar
· 11,812 Views · 4 Likes
article thumbnail
2-Step Resource Versioning With Spring MVC
These two simple steps will allow you to configure versioned resource URLs in Spring MVC, allowing the browser to cache resources for an unlimited time and update version info on the URL when a resource is changed.
September 22, 2015
by Michael Scharhag
· 25,082 Views · 5 Likes
article thumbnail
Low Latency FIX Engine in Java
Chronicle FIX is a low latency FIX database for Java. Check out why it's so awesome and boosts performance.
September 22, 2015
by Peter Lawrey
· 8,387 Views · 1 Like
article thumbnail
MySQL: Server vs. Client-Side Prepared Statements in Java
Basically, there are two ways of preparing a statement: on the server-side or on the client-side.
September 22, 2015
by Vlad Mihalcea
· 10,344 Views · 3 Likes
article thumbnail
Applying Gaussian Blur to UIViews with Swift Protocol Extensions
Here's a fun little experiment showing the power of Swift's Protocol Extensions to apply a CIGaussianBlur Core Image filter to any UIView with no developer overhead. The code could be extended to apply any Core Image filter such as a half tone screen or colour adjustment. Blurable is a simple protocol that borrows some of the methods and variables from a UIView: var layer: CALayer { get } var subviews: [UIView] { get } var frame: CGRect { get } func addSubview(view: UIView) func bringSubviewToFront(view: UIView) ...and adds a few of its own: Obviously, just being a protocol, it doesn't do much on its own. However, by adding an extension, I can introduce default functionality. Furthermore, by extending UIView to implement Blurable, every component from a segmented control to a horizontal slider can be blurred: extension UIView: Blurable { } The Mechanics of Blurable Getting a blurred representation of a UIView is pretty simple: I need to begin an image context, use the view's layer's renderInContext method to render into the context and then get a UIImage from the context: UIGraphicsBeginImageContextWithOptions(CGSize(width: frame.width, height: frame.height), false, 1) layer.renderInContext(UIGraphicsGetCurrentContext()!) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext(); Once I have the image populated, it's a fairly standard workflow to apply a Gaussian blur to it: guard let blur = CIFilter(name: "CIGaussianBlur") else { return } blur.setValue(CIImage(image: image), forKey: kCIInputImageKey) blur.setValue(blurRadius, forKey: kCIInputRadiusKey) let ciContext = CIContext(options: nil) let result = blur.valueForKey(kCIOutputImageKey) as! CIImage! let boundingRect = CGRect(x: -blurRadius * 4, y: -blurRadius * 4, width: frame.width + (blurRadius * 8), height: frame.height + (blurRadius * 8)) let cgImage = ciContext.createCGImage(result, fromRect: boundingRect) let filteredImage = UIImage(CGImage: cgImage) A blurred image will be larger than its input image, so I need to be explicit about the size I require in createCGImage. The next step is to add a UIImageView to my view and hide all the other views. I've subclassed UIImageView to BlurOverlay so that when it comes to removing it, I can be sure I'm not removing an existing UIImageView: let blurOverlay = BlurOverlay() blurOverlay.frame = boundingRect blurOverlay.image = filteredImage subviews.forEach{ $0.hidden = true } addSubview(blurOverlay) When it comes to de-blurring, I want to ensure the last subview is one of my BlurOverlay remove it and unhide the existing views: func unBlur() { if let blurOverlay = subviews.last as? BlurOverlay { blurOverlay.removeFromSuperview() subviews.forEach{ $0.hidden = false } } } Finally, to see if a UIView is currently blurred, I just need to see if its last subview is a BlurOverlay: var isBlurred: Bool { return subviews.last is BlurOverlay } Blurring a UIView To blur and de-blur, just invoke blur() and unBlur() on an UIView: segmentedControl.unBlur() segmentedControl.blur(blurRadius: 2) Source Code As always, the source code for this project is available at my GitHub repository here. Enjoy!
September 21, 2015
by Simon Gladman
· 14,761 Views · 2 Likes
article thumbnail
What is Allocation Rate?
This post will try to remove the magic from the phrases "unsustainable allocation rate" and "keeping your allocation rates low."
September 21, 2015
by Nikita Salnikov-Tarnovski
· 6,442 Views · 2 Likes
article thumbnail
Displaying Progress of Spring Application Startup in the Browser
When you restart your enterprise application, what do your clients see when they open the web browser?
September 21, 2015
by Tomasz Nurkiewicz
· 18,296 Views · 3 Likes
article thumbnail
Custom Operators for Collections in Java
Learn how to use operator overloading in Java, using it's existing conventions.
September 21, 2015
by Peter Lawrey
· 19,488 Views · 6 Likes
article thumbnail
Spring Security 4: JDBC Authentication and Authorization in MySQL
I am going to explain how to use Spring Security in a Spring MVC Application to authenticate and authorize users against user details stored in a MySQL Database.
September 18, 2015
by Priyadarshini Balachandran
· 192,713 Views · 10 Likes
article thumbnail
Microservices Versus Microsegmentation
An exploration of the difference between the concepts of microservices and microsegmentation.
September 17, 2015
by Lori MacVittie
· 7,206 Views · 5 Likes
article thumbnail
Velocity Momentum: How to Make It Work for Project Planning and Management
Insights on how to make an average velocity concept a powerful tool for your Agile team.
September 17, 2015
by Darya Korsak
· 5,033 Views · 1 Like
article thumbnail
Optimizing a Hashing Strategy
Using two strategies in combination you can develop new hashing strategies to improve performance without having to use more memory or much more CPU.
September 16, 2015
by Peter Lawrey
· 14,057 Views · 1 Like
article thumbnail
Receive Notifications when a Table Record Changes with C#
The SQLDependency object represents a query notification dependency between an application and an instance of SQL Server. An application can create a SqlDependency object and register to receive notifications via the OnChangeEventHandler event handler every time a record is changed. However, what it cannot do, is returning the values for the inserted, modified or deleted record. So, supposing our application has a cache containing record monitored from SqlDependency, for every notification, in order to refresh the cache we have to execute again our select. SqlTableDependency SqlTableDependency is a generic C# component used to receive events containing the values for the modified, inserted or delete record. So, supposing our application has a cache filled with data got from a specific table, when its content change, we will receive an event containing a C# object with all property filled with column table values. How it Works When instantiated, SqlTableDependency create for us, a series of database objects, used to monitor a predefined table. The main object are: Queue: containg a message with the modified record values. Service Broker: insert the message in the queue. Table Trigger: for each insert, update or delete operation, prepare the an XML message and use the Service Broker to insert it in the queue. Watch Dog Time Out SqlTableDependency implement the IDisposable interface, in order to remove the database object created. Infact it is a good practice is to wrap SqlTableDependency within a using statement or, alternatively, call the Stop() method once we do not need any more notifications. So, when the application will not disconnect abruptly, this approach is enough to remove the SqlTableDependency infrastructure (Trigger, Service Broker service, Queue). However, when the application exits abruptly – that is not calling the Stop() method or not implementing the using statement - we need a way for cleaning up the SqlTableDependency infrastructure. The Start() method, has watchDogTimeOut optional parameter used to remove all the database objects. Its default value is 180 seconds: after this amount of time, if there are no listeners waiting for notifications, the SqlTableDependency infrastructure will be removed. How to Use In this example I created a very simple WPF application with a grid, simulating some stocks value. Let's start assuming the following database table: CREATE TABLE [dbo].[Stocks]( [Code] [nvarchar](50) NULL, [Name] [nvarchar](50) NULL, [Price] [decimal](18, 0) NULL) GO INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'MCD', N'McDonald Corp', CAST(333 AS Decimal(18, 0))) INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'NKE', N'Nike Inc', CAST(240 AS Decimal(18, 0))) INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'DIS', N'Walt Disney Co', CAST(130 AS Decimal(18, 0))) INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'UTX', N'United Technologies Corp', CAST(130 AS Decimal(18, 0))) INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'MSFT', N'Microsoft Corp', CAST(130 AS Decimal(18, 0))) INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'PFE', N'Pfizer Inc', CAST(130 AS Decimal(18, 0))) INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'INTC', N'Intel Corp', CAST(130 AS Decimal(18, 0))) INSERT [dbo].[Stocks] ([Code], [Name], [Price]) VALUES (N'KO', N'Coca Cola Co', CAST(130 AS Decimal(18, 0))) GO This table is constantly updated with new stock values. We want keep update our grid without use of any polling system. So, what we need is a notification coming from the database every time a record in the table has been changed. We install the SqlTableDependency package from visual studio using the following command: PM> Install-Package SqlTableDependency Now we define a C# model mapping the interested table columns. public class Stock { public decimal Price { get; set; } public string Symbol { get; set; } public string Name { get; set; } } As you can see, model's properties name can have a different table column name. In this case, we need a mapper to correclty bind the values: var mapper = new ModelToTableMapper(); mapper.AddMapping(model => model.Symbol, "Code"); Finally we create our SqlTableDependency: _dependency = new SqlTableDependency(_connectionString, "Stocks", mapper); _dependency.OnChanged += _dependency_OnChanged; _dependency.OnError += _dependency_OnError; _dependency.Start(); Below the complete code: public partial class Window1 : Window { private IList _stocks; private readonly string _connectionString = "data source=.;initial catalog=TableDependencyDB;integrated security=True"; private readonly SqlTableDependency _dependency; public Window1() { this.InitializeComponent(); this.McDataGrid.ItemsSource = LoadCollectionData(); this.Closing += Window1_Closing; var mapper = new ModelToTableMapper(); mapper.AddMapping(model => model.Symbol, "Code"); _dependency = new SqlTableDependency(_connectionString, "Stocks", mapper); _dependency.OnChanged += _dependency_OnChanged; _dependency.OnError += _dependency_OnError; _dependency.Start(); } private void Window1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { _dependency.Stop(); } private void _dependency_OnError(object sender, TableDependency.EventArgs.ErrorEventArgs e) { throw e.Error; } private void _dependency_OnChanged(object sender, TableDependency.EventArgs.RecordChangedEventArgs e) { if (_stocks != null) { if (e.ChangeType != ChangeType.None) { switch (e.ChangeType) { case ChangeType.Delete: _stocks.Remove(_stocks.FirstOrDefault(c => c.Symbol == e.Entity.Symbol)); break; case ChangeType.Insert: _stocks.Add(e.Entity); break; case ChangeType.Update: var customerIndex = _stocks.IndexOf(_stocks.FirstOrDefault(c => c.Symbol == e.Entity.Symbol)); if (customerIndex >= 0) _stocks[customerIndex] = e.Entity; break; } this.McDataGrid.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() => { this.McDataGrid.Items.Refresh(); })); } } } private IEnumerable LoadCollectionData() { _stocks = new List(); using (var sqlConnection = new SqlConnection(_connectionString)) { sqlConnection.Open(); using (var sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.CommandText = "SELECT * FROM [Stocks]"; using (var sqlDataReader = sqlCommand.ExecuteReader()) { while (sqlDataReader.Read()) { var code = sqlDataReader.GetString(sqlDataReader.GetOrdinal("Code")); var name = sqlDataReader.GetString(sqlDataReader.GetOrdinal("Name")); var price = sqlDataReader.GetDecimal(sqlDataReader.GetOrdinal("Price")); _stocks.Add(new Stock { Symbol = code, Name = name, Price = price }); } } } } return _stocks; } } As you can see from the code, only an initial select is performed to retrieve and populate the grid. Subsequent updates are done using the SqlTableDependency event handler: its receives a model object containing info about the record changed that we use to update our cache.
September 16, 2015
by Christian Del Bianco
· 141,510 Views · 5 Likes
article thumbnail
STRUTS 2 vs SPRINGMVC: Know the Difference & Choose the Best One Based On Your Requirements
Apache Struts 2 and SpringMVC, these two are the most popular and much talked about Java web frameworks today. Many of you might have worked with both of these frameworks, but which is one is better to use? What are the basic differences between both of these frameworks? Well, Apache Struts 2 is an elegant and extensible framework that is used for creating enterprise-level Java web applications. It is designed to streamline the development cycle, starting from building to deployment and maintenance of the application. In Struts, the object that is taking care of a request and routes it for further processing is known as “Action”. On the other hand, Spring MVC is a part of a huge Spring framework stack containing other Spring modules. This means that it doesn’t allow developers to run it without Spring, but the developers can run the Spring Core without Spring MVC. The Spring MVC (Model View Controller) is designed around a DispatcherServlet, which dispatches the requests to handler with configurable handler mappings, view resolution and theme resolution. While the objects responsible for handling requests and routing for processing in Struts called an Action, the same object is referred as Controller in Spring Web MVC framework. This is one of the very first differences between Spring MVC and Struts2. Struts 2 Actions are initiated every time when a request is made, whereas in Spring MVC the Controllers are created only once, stored in memory and shared among all the requests. So, Spring Web MVC framework is far efficient to handle the requests than Struts 2. If we talk about the features, Struts 2 and Spring MVC framework caters different level of business requirements. Let’s take a look at features offered by both of these frameworks. Struts 2 features Configurable MVC components, which are stored in struts.xml file. If you want to change anything, you can easily do it in the xml file. POJO based actions. Struts 2 action class is Plain Old Java Object, which prevents developers to implement any interface or inherit any class. Support for Ajax, which is used to make asynchronous request. It only sends needed field data rather than providing unnecessary information, which at the end improves the performance. Support for integration with Hibernate, Spring, Tiles and so on. Whether you want to use JSP, freemarker, velocity or anything else, you can use different kinds of result types in Struts 2. You can also leverage from various tags like UI tags, Data tags, control tags and more. Brings ample support for theme and template. Struts 2 supports three different kinds of themes including xhtml, simple and css_xhtml. On the other hand, Spring MVC framework brings totally different set of features. Spring MVC features Neat and clear separation of roles. Whether it is controller, command object, form object or anything else, it can be easily fulfilled with the help of a specialized object. Leverage from the adaptability, non-intrusiveness and flexibility with the help of controller method signature. Now use existing business objects as command or form object rather than duplicating them to extend the specific framework base class. Customizable binding and validation will enable manual parsing and conversion to business objects rather than using conventional string. Flexible mode transfer enables easy integration with the latest technology. Customizable locale and theme resolution, support for JSPs with or without Spring tag library for JSTL and so on. Leverage from the simple, but powerful JSP tag library known as Spring tag library. It provides support for various features like data binding and themes. Of course, Struts is one of the most powerful Java application frameworks that can be used in a variety of Java applications. It brings a gamut of services that includes enterprise level services to the POJO. On the other hand, Spring utilizes the dependency injection to achieve the simplification and enhance the testability. Both of these frameworks have their own set of pros and cons associated with it. Struts framework brings a whole host of benefits including: Simplified design Ease of using plug-in Simplified ActionForm & annotations Far better tag features OGNL integration AJAX Support Multiple view options and more However, the only drawback with Struts 2 framework is that it has compatibility issues and poor documentation. On the other hand, Spring MVC provides benefits like: Clear separation between controllers, JavaBeans models and views that is not possible in Struts. Spring MVC is more flexible as compared to the Struts. Spring can be used with different platforms like Velocity, XLST or various other view technologies. There is nothing like ActionForm in Spring, but binds directly to the domain objects. Code is also more testable as compared to the Struts. It is a complete J2EE framework comprising of seven independent layers, which simplifies integration with other frameworks. It doesn’t provide a framework for implementing the business domain and logic, which helps developers create a controller and a view for the application. However, like any other technologies or platforms, Spring MVC too suffers from several criticisms related to the complexity of the Spring framework. Final Verdict Either framework is a great choice. However, if you’re looking for the stable framework, Struts 2 is the right choice for you. On the other hand, if you’re looking for something robust, SpringMVC is perfect. Ensure that you review your exact requirements before choosing the framework!
September 15, 2015
by Manmay Mehta
· 32,391 Views · 4 Likes
article thumbnail
Why Many Return Statements Are a Bad Idea in OOP
Multiple return statements in a method will cause your code not to be purely object-oriented. Here you'll find an example where you can use a clean OOP approach instead of using multiple returns.
September 15, 2015
by Yegor Bugayenko
· 47,199 Views · 7 Likes
article thumbnail
Data Conversion for SQL Server Integration Services (SSIS)
In the series of step by step lessons of SSIS (SQL Server Integration Services), this is part six in which we are going to learn a new control: Data Conversion.
September 15, 2015
by Rajat Jaiswal
· 18,174 Views · 1 Like
article thumbnail
When Do You Stop Testing?
You stop testing when there are no more bugs, right? If so, you're doing something fundamentally wrong.
September 14, 2015
by Yegor Bugayenko
· 6,789 Views · 3 Likes
  • Previous
  • ...
  • 1446
  • 1447
  • 1448
  • 1449
  • 1450
  • 1451
  • 1452
  • 1453
  • 1454
  • 1455
  • ...
  • Next
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook
×