Welcome!

Java IoT Authors: Stackify Blog, Pat Romanski, Liz McMillan, Elizabeth White, Yeshim Deniz

Related Topics: Java IoT

Java IoT: Article

KISS + Swing = RAD

How to rapidly develop enterprise class Swing applications by keeping things simple

/// This is a sample embeddable class representing an address.
Class base.Address Extends %SerialObject [ ClassType = serial, ProcedureBlock ]
{

Projection JavaClient As %Projection.Java;

/// Specify the proper Java Package
Parameter JAVAPACKAGE = "com.egrok.db.base";

/// The street address.
Property Street As %String(MAXLEN = 80);

/// The city name.
Property City As %String(MAXLEN = 80);

/// The 2-letter state abbreviation.
Property State As %String(MAXLEN = 2);

/// The 5-digit U.S. Zone Improvement Plan (ZIP) code.
Property Zip As %String(MAXLEN = 5);

}

The Person Class
Note that the Person class is being projected as a Java class in the package "com.egrok.db.base" and that the Person class has two properties that are derived from the serial address class: HomeAddress and WorkAddress. When you access these properties from the Java class, you'll use standard dot notation as follows:

Class base.Person Extends %Persistent [ ClassType = persistent, ProcedureBlock ]
{

Projection JavaClient As %Projection.Java;

/// Specify the proper Java Package
Parameter JAVAPACKAGE = "com.egrok.db.base";
Property Name As %String [ Required ];

Property LastName As %String;

Property HomeAddress As base.Address;

Property WorkAddress As base.Address;

Property Notes As %String(MAXLEN = 1000);
Property DateCreated As %TimeStamp;

/// Person is registered with the mailing list
Property IsRegistered As %Boolean;
}

person.getHomeAddress().getStreet();

The Employee Class

Class base.Employee Extends base.Person [ ClassType = persistent, ProcedureBlock ]
{

Projection JavaClient As %Projection.Java;

/// Specify the proper Java Package
Parameter JAVAPACKAGE = "com.egrok.db.base";

/// Specify the required property username
Property UserName As %String [ Required ];

/// Specify the username property must be unique
Index UserNameIndex On UserName [ Unique ];

Property Password As %String [ Required ];

/// The employee's current work status. Used when assigning jobs dynamically
Property WorkStatus As %String(VALUELIST = ",Available,Sick,Vacation,UnAvailable");

/// Defines a one to many relationship between the Department Object and Employee Objects
Relationship Department As base.Department [ Cardinality = one, Inverse = Employees ];

/// Defines an index on the Department property
Index DepartmentIndex On Department;

/// Specify the Employee's Manager - Example of Aggregation
Property Manager As base.Employee;
}

Here you can see that the Employee class extends the Person class and thus inherits all the properties and methods associated with the Person class. New properties specific to the Employee class are also added including a one-to-many relationship with the Department class and a reference to another employee, the Manager (an example of aggregation). We won't go into the details of parent/child and one-to-many relationships here since it's beyond the scope of this article.

Once again a Java Projection is defined. When you compile your class definitions, Java classes that provide access to the objects in the database will be created in the specified package. Simply by defining your database, you get access to pure Java objects that can be instantiated and persisted without any other code or mapping frameworks.

Tip: As with any Java class, you can extend the Java classes created by Caché (Java Projections) and add custom methods to them. Your application should then access these extended classes. This will insulate your application from most changes made to the class definition and preserve your custom methods, which would be overwritten the next time you compiled the database definition if you modify the Caché projection classes directly.

Example: Instantiating a Persistent Object
Listing 1 shows how to instantiate and access the Employee Java object from your Java code as well as some examples of how to access the data just as you would any other Java object.

That's it - straightforward Java objects. Just like any other persistence mechanism, you must connect to the database. However, once you've done that, you can access the object using standard dot notation. As you can see, you can also access linked objects (department and manager, for example) in the same manner without the need for creating multi-table SQL Joins. And remember - you've eliminated the need to define and maintain complex XML mappings for a JDO persistence layer!

Caché Tip: Use Caché's SQL projection when you are doing complex selection queries and updates to multiple objects at the same time. Use Caché's Object projection when dealing with a single object or linked objects.

Why Too Many Technologies Make Development and Maintenance Difficult
At this point, you've seen how to dramatically simplify and accelerate development on the server side, but you still need to get the data to the client and present it to the end user. Look under the hood of many Web -based applications today and you'll see a vast array of technologies and frameworks in use. A typical Struts application will require knowledge of HTML, JSP, XML, Java, and perhaps JSF and JavaScript. In addition, you have to learn Struts and possibly Tiles and some sort of Validation framework. (We'll forget about SQL and JDO for now, since we've solved that by using an object database.)

More Stories By Richard Conway

Richard Conway is a software developer and technology consultant with more than 15 years of technology, project management, and information services experience. He has extensive experience developing Java/Struts-based web applications. He started focusing more on Swing based developments at the beginning of 2005 and has just finished a Swing-based client/server asset management project. He lives in Miami with his wife Patricia, is currently working on an EMR application, and plays sand volleyball in his spare time.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
When growing capacity and power in the data center, the architectural trade-offs between server scale-up vs. scale-out continue to be debated. Both approaches are valid: scale-out adds multiple, smaller servers running in a distributed computing model, while scale-up adds fewer, more powerful servers that are capable of running larger workloads. It’s worth noting that there are additional, unique advantages that scale-up architectures offer. One big advantage is large memory and compute capacity...
In his session at @ThingsExpo, Eric Lachapelle, CEO of the Professional Evaluation and Certification Board (PECB), provided an overview of various initiatives to certify the security of connected devices and future trends in ensuring public trust of IoT. Eric Lachapelle is the Chief Executive Officer of the Professional Evaluation and Certification Board (PECB), an international certification body. His role is to help companies and individuals to achieve professional, accredited and worldwide re...
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
No hype cycles or predictions of zillions of things here. IoT is big. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, Associate Partner at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He discussed the evaluation of communication standards and IoT messaging protocols, data analytics considerations, edge-to-cloud tec...
Amazon started as an online bookseller 20 years ago. Since then, it has evolved into a technology juggernaut that has disrupted multiple markets and industries and touches many aspects of our lives. It is a relentless technology and business model innovator driving disruption throughout numerous ecosystems. Amazon’s AWS revenues alone are approaching $16B a year making it one of the largest IT companies in the world. With dominant offerings in Cloud, IoT, eCommerce, Big Data, AI, Digital Assista...
SYS-CON Events announced today that CA Technologies has been named "Platinum Sponsor" of SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CA Technologies helps customers succeed in a future where every business - from apparel to energy - is being rewritten by software. From planning to development to management to security, CA creates software that fuels transformation for companies in the applic...
Artificial intelligence, machine learning, neural networks. We’re in the midst of a wave of excitement around AI such as hasn’t been seen for a few decades. But those previous periods of inflated expectations led to troughs of disappointment. Will this time be different? Most likely. Applications of AI such as predictive analytics are already decreasing costs and improving reliability of industrial machinery. Furthermore, the funding and research going into AI now comes from a wide range of com...
Multiple data types are pouring into IoT deployments. Data is coming in small packages as well as enormous files and data streams of many sizes. Widespread use of mobile devices adds to the total. In this power panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists looked at the tools and environments that are being put to use in IoT deployments, as well as the team skills a modern enterprise IT shop needs to keep things running, get a handle on all this data, and deliver...
Internet of @ThingsExpo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devic...
SYS-CON Events announced today that Cloud Academy named "Bronze Sponsor" of 21st International Cloud Expo which will take place October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara, CA. Cloud Academy is the industry’s most innovative, vendor-neutral cloud technology training platform. Cloud Academy provides continuous learning solutions for individuals and enterprise teams for Amazon Web Services, Microsoft Azure, Google Cloud Platform, and the most popular cloud com...
SYS-CON Events announced today that Enzu will exhibit at SYS-CON's 21st Int\ernational Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Enzu’s mission is to be the leading provider of enterprise cloud solutions worldwide. Enzu enables online businesses to use its IT infrastructure to their competitive advantage. By offering a suite of proven hosting and management services, Enzu wants companies to focus on the core of their ...
We build IoT infrastructure products - when you have to integrate different devices, different systems and cloud you have to build an application to do that but we eliminate the need to build an application. Our products can integrate any device, any system, any cloud regardless of protocol," explained Peter Jung, Chief Product Officer at Pulzze Systems, in this SYS-CON.tv interview at @ThingsExpo, held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA
SYS-CON Events announced today that GrapeUp, the leading provider of rapid product development at the speed of business, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Grape Up is a software company, specialized in cloud native application development and professional services related to Cloud Foundry PaaS. With five expert teams that operate in various sectors of the market acr...
SYS-CON Events announced today that Ayehu will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara California. Ayehu provides IT Process Automation & Orchestration solutions for IT and Security professionals to identify and resolve critical incidents and enable rapid containment, eradication, and recovery from cyber security breaches. Ayehu provides customers greater control over IT infras...
SYS-CON Events announced today that MobiDev, a client-oriented software development company, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MobiDev is a software company that develops and delivers turn-key mobile apps, websites, web services, and complex software systems for startups and enterprises. Since 2009 it has grown from a small group of passionate engineers and business...
In his session at Cloud Expo, Alan Winters, an entertainment executive/TV producer turned serial entrepreneur, presented a success story of an entrepreneur who has both suffered through and benefited from offshore development across multiple businesses: The smart choice, or how to select the right offshore development partner Warning signs, or how to minimize chances of making the wrong choice Collaboration, or how to establish the most effective work processes Budget control, or how to ma...
"When we talk about cloud without compromise what we're talking about is that when people think about 'I need the flexibility of the cloud' - it's the ability to create applications and run them in a cloud environment that's far more flexible,” explained Matthew Finnie, CTO of Interoute, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
IoT solutions exploit operational data generated by Internet-connected smart “things” for the purpose of gaining operational insight and producing “better outcomes” (for example, create new business models, eliminate unscheduled maintenance, etc.). The explosive proliferation of IoT solutions will result in an exponential growth in the volume of IoT data, precipitating significant Information Governance issues: who owns the IoT data, what are the rights/duties of IoT solutions adopters towards t...
With the introduction of IoT and Smart Living in every aspect of our lives, one question has become relevant: What are the security implications? To answer this, first we have to look and explore the security models of the technologies that IoT is founded upon. In his session at @ThingsExpo, Nevi Kaja, a Research Engineer at Ford Motor Company, discussed some of the security challenges of the IoT infrastructure and related how these aspects impact Smart Living. The material was delivered interac...