ACS Error System Using it in JAVA Sohaila Lucero NRAO.

Slides:



Advertisements
Similar presentations
Exception Handling – illustrated by Java mMIC-SFT November 2003 Anders P. Ravn Aalborg University.
Advertisements

Exceptions Don’t Frustrate Your User – Handle Errors KR – CS 1401 Spring 2005 Picture – sysprog.net.
Exceptions and Exception Handling Carl Alphonce CSE116 March 9, 2007.
Exceptions1 Syntax, semantics, and pragmatics. Exceptions2 Syntax, semantics, pragmatics Syntax –How it looks, i.e. how we have to program to satisfy.
SE-1020 Dr. Mark L. Hornick 1 Exceptions and Exception Handling.
Java Programming Exceptions. Java has a built in mechanism for error handling and trapping errors Usually this means dealing with abnormal events or code.
EXCEPTIONS. What’s an exception?? Change the flow of control when something important happens ideally - we catch errors at compile time doesn’t happen.
Exceptions and Exception Handling Carl Alphonce CSE116.
Exceptions1 Syntax, semantics, and pragmatics. Exceptions2 Syntax, semantics, pragmatics Syntax –How it looks, i.e. how we have to program to satisfy.
Java Exceptions. Types of exceptions  Checked exceptions: A checked exception is an exception that is typically a user error or a problem that cannot.
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
Java/C++ Exceptions and Message Logging Language-independent exception definition/handling and general message logging. (Adventures in Middleware) Ron.
Exceptions and Exception Handling (1) Carl Alphonce CSE116.
Java/C++ eExceptions and Message Logging Language-independent exception definition/handling and general message logging. (Adventures in Middleware) Ron.
1 From Yesterday private = accessible only to the class that declares it public = accessible to any class at all protected = accessible to the class and.
16-Jun-15 Exceptions. Errors and Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a null.
Exceptions CIS 304 Intermediate Java Programming for Business.
Exceptions. Errors and Exceptions An error is a bug in your program –dividing by zero –going outside the bounds of an array –trying to use a null reference.
CS203 Java Object Oriented Programming Errors and Exception Handling.
1 Web Based Programming Section 6 James King 12 August 2003.
Exception Handling. Exceptions and Errors When a problem encounters and unexpected termination or fault, it is called an exception When we try and divide.
CIS 270—Application Development II Chapter 13—Exception Handling.
ESO - Garching 23 June – 02 July, 2003 ACS Course Data entities and XML serialization H. Sommer.
Exceptions1 Syntax, semantics, and pragmatics. Exception create If (some error){ throw new SomeException(”some message”); } Exceptions2.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
The Java Inheritance Hierarchy CSIS 3701: Advanced Object Oriented Programming.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
 No move to Java 7 until end of this year  IT deploy Java 7 everywhere  BE/CO remove it again!  So don’t rely on it being installed on a console 
Exceptions Syntax, semantics, and pragmatics Exceptions1.
Data Structures and Java CS 105. L7: Java Slide 2 Data structure Data structure defined: A systematic way of organizing and accessing data Examples Dictionary:
JSP Exception Handling 20-Oct-15. JSP - E XCEPTION H ANDLING When you are writing JSP code, a programmer may leave a coding errors which can occur at.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 10.
Introduction to Exception Handling and Defensive Programming.
CORBA – Command Line CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
ACS Error System APIs: C++ Bogdan Jeram European Southern Observatory July 2005ESO.
AtacamaLargeMillimeterArray ACS Training Developing Python Components.
Software Documentation Section 5.5 ALBING’s Section JIA’s Appendix B JIA’s.
ESO - Garching 23 June – 02 July, 2003 ACS Course JUnit for Java Unit Testing H. Sommer.
Object Oriented Software Development
CORBA – Eclipse CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Exceptions, cont’d. Factory Design Pattern COMP 401 Fall 2014 Lecture 12 9/30/2014.
1 Implementing LEAP2A using the Argotic library in.NET Andrew Everson Extensions for Argotic version can be downloaded from:
ESO - Garching 23 June – 02 July, 2003 ACS Course Transparent XML De-/Serialization in Java H. Sommer.
1 Exception handling in Java Reading for this lecture: Weiss, Section 2.5 (exception handling), p. 47. ProgramLive, chapter 10. I need to know whether.
CSC 243 – Java Programming, Spring, 2009 Week 9 Java’s Event Infrastructure.
Data Structures and Java CS /14/2015 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L6:
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 15 Inheritance.
CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming –TextField Action Listeners, JEditorPane action listeners, HTML in a JEditorPane,
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Today: –Review declaration, implementation, simple class structure. –Add an exception class and show.
January 25, 2016 First experiences with CORBA Niko Neufeld.
AtacamaLargeMillimeterArray ACS Training Using the Python Error System.
Java Programming: Exceptions1 Exceptions Reference: java.sun.com/docs/books/tutorial/essential/exceptions/
Exception Handling in C + + Introduction Overview of C++ Exception Handling Designing With Exceptions Exception Handling Philosophies Conclusion.
Exceptions Lecture 11 COMP 401, Fall /25/2014.
Lecture10 Exception Handling Jaeki Song. Introduction Categories of errors –Compilation error The rules of language have not been followed –Runtime error.
COP 3330 Notes 3/7. Today’s Topics Exceptions Abstract Classes.
ESO - Garching 08 – 09 March, st ALMA Common Software Workshop XML « Data by Value » Transport.
Exceptions and Error Handling. Exceptions Errors that occur during program execution We should try to ‘gracefully’ deal with the error Not like this.
Introduction to Exceptions in Java CS201, SW Development Methods.
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
Generics, Exceptions and Undo Command
Creating and Modifying Text part 2
Chapter 12 Exception Handling and Text IO
Exceptions 10-Nov-18.
Handling Exceptions.
Java Programming Language
Exception Handling in Java
Exceptions 10-May-19.
Lab 1 Exception Handling.
Presentation transcript:

ACS Error System Using it in JAVA Sohaila Lucero NRAO

JAVA developers will find the JAVA implementation of the ACS Error System similar to the exception handling in the JAVA Development Kit (JDK). Like C++ and Python, there are wrapper classes generated to help developers. These classes are used to translate between the native linked exception structure of JAVA (“caused-by”) and the awkward structure required for CORBA. These wrapper classes are all pre-pended by “AcsJ”.

Advantages of this implementation! With the “AcsJ-” exception wrapper classes, Java components can use standard JDK exception handling: –Exception inheritance hierarchy instead of type/code numbers: can catch exceptions by ErrorType –Easy daisy-chaining by adding cause exception in constructor –Seamless linking of java.lang.xyz exceptions or those from other packages (such as SAXParserException) Recall, CORBA does not support hierarchical exception structures.

The difference between “Inheritance Hierarchy” and “Daisy-chaining” Inheritance Hierarchy java.lang.Throwable java.lang.Exception Type1 Type2 Code1Ex Code2Ex Daisy-chaining (linking of exceptions) NullPointerException MyFirstException MyNextException

All code for the next example can be found in CVS in the following directory: ACS/LGPL/CommonSoftware/jcontexmpl

An Example! First the XML definitions of the errors. <Type xmlns:xsi=" xsi:noNamespaceSchemaLocation="ACSError.xsd" name="ErrorSystemExample" type="13" _prefix="alma"> <ErrorCode name="NothingCanBeScheduledError" shortDescription="Error in Scheduling System" description="Nothing could be scheduled error"/> <ErrorCode name="PipelineProcessingRequestError" shortDescription="Error with pipeline processing request" description="1"/> Must be unique to ALMA Assigned by Software Engineering group.

The previous XML document defines 1 error type, ErrorSystemExample, which contains these 2 error codes. NothingCanBeScheduledError and PipelineProcessingRequest

An Example! The IDL [automatically] generated from the previous XML. #ifndef _ErrorSystemExample_IDL_ #define _ErrorSystemExample_IDL_ #include #pragma prefix "alma" module ACSErr { // type const ACSErr::ACSErrType ErrorSystemExample = 13; }; // module ACSErr //more on next slide

module ErrorSystemExample { const ACSErr::ErrorCode NothingCanBeScheduledError = 0; const ACSErr::ErrorCode PipelineProcessingRequestError = 1; // excption for type: exception ErrorSystemExampleEx { ACSErr::ErrorTrace errorTrace; }; // excptions for codes: exception NothingCanBeScheduledErrorEx { ACSErr::ErrorTrace errorTrace; }; exception PipelineProcessingRequestErrorEx { ACSErr::ErrorTrace errorTrace; }; }; // module ErrorSystemExample #endif The error codes mapped to IDL Exceptions. Each containing the ErrorTrace from ACS. Notice the Ex appended to each.

An Example! Using the new exceptions in a IDL! Don’t forget to include the generated IDL file which has the exceptions defined! #include IDL Methods: void tryToScheduleSomething() raises (ErrorSystemExample::NothingCanBeScheduledErrorEx); void tryToProcessSomething() raises (ErrorSystemExample::PipelineProcessingRequestErrorEx); void usingWrapperClasses1() raises (ErrorSystemExample::NothingCanBeScheduledErrorEx); void usingWrapperClasses2(); Now that the error codes are mapped to IDL we can use them like any other exception in our IDL files

An Example! Simple implementations of the IDL methods. public void tryToScheduleSomething() throws NothingCanBeScheduledErrorEx { String schedblock = null; try { if(schedblock != null) { //Schedule it! } else { throw new NullPointerException("Can't scheduled a null SB!"); } } catch (NullPointerException e) {. AcsJNothingCanBeScheduledErrorEx e2 = new AcsJNothingCanBeScheduledErrorEx(e); throw e2.toNothingCanBeScheduledErrorEx(); } Since the SchedBlock is null we throw a NullPointer exceptiopn Then we catch that exception and using the generated wrapper classes we create our NothingCanBeScheduled exception with it. This creates a hierarchical exception chain. Then using a function in the wrapper class we convert our exception to something that CORBA will understand and we throw that exception.

An Example! continued… public void tryToProcessSomething() throws PipelineProcessingRequestErrorEx { //Trying to process something. try { tryToScheduleSomething(); } catch(NothingCanBeScheduledErrorEx e) { AcsJPipelineProcessingRequestErrorEx e2 = new AcsJPipelineProcessingRequestErrorEx(e); throw e2.toPipelineProcessingRequestErrorEx(); } Use our previous method to get an exception Using the wrapper classes for our other exception, we create an exception retaining the hierarchical structure. And again we convert it to an exception that CORBA will understand.

An Example! continued… public void usingWrapperClasses1() throws NothingCanBeScheduledErrorEx { try { throw new AcsJNothingCanBeScheduledErrorEx("Couldn't scheduled due to bad weather!"); `` } catch(AcsJErrorSystemExampleEx e){ throw ((AcsJNothingCanBeScheduledErrorEx)e).toNothingCanBeScheduledErrorEx(); } Using the wrapper classes we can take advantage of super/base classes. NOTE: This is only possible with the wrapper classes since CORBA does not support exception inheritance.

An Example! What objexp shows when an error is thrown!

An Example! continued… public void usingWrapperClasses2() { try { throw new AcsJNothingCanBeScheduledErrorEx("Testing printStackTrace!"); } catch(AcsJErrorSystemExampleEx e) { e.printStackTrace(); } Since the wrapper classes generated for our exceptions all inherit from the JAVA Exception class we can use the functions like printStackTrace()

An Example! What the stack trace looks like. alma.ErrorSystemExample.wrappers.AcsJNothingCanBeScheduledErrorEx: Testing printStackTrace! at alma.demo.ErrorSystemComp.ErrorSystemImpl.usingWrapperClasses2(ErrorSystemImpl.java:78) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at alma.acs.container.ContainerSealant.invoke(ContainerSealant.java:115) at $Proxy0.usingWrapperClasses2(Unknown Source) at alma.demo.ErrorSystemPOATie.usingWrapperClasses2(ErrorSystemPOATie.java:43) at alma.demo.ErrorSystemPOA._invoke(ErrorSystemPOA.java:46) at org.jacorb.poa.RequestProcessor.invokeOperation(Unknown Source) at org.jacorb.poa.RequestProcessor.process(Unknown Source) at org.jacorb.poa.RequestProcessor.run(Unknown Source)

Too much to take in now? Everything from this presentation is discussed in more detail in Section 8 in the ACS Error System document found on the ACS webpage.