diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 16:07:07 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 16:07:07 +0000 |
commit | fd069bee7e57ad529c3c0974559fd2d84ec3151a (patch) | |
tree | ef2eddeefb786feaf966d6a1c0c291872c0ae420 /sj2 | |
parent | 04c1c754ab9d0ad07f2c5362d46597d13efe75c2 (diff) |
initial import
Diffstat (limited to 'sj2')
27 files changed, 5809 insertions, 0 deletions
diff --git a/sj2/doc/Todo.txt b/sj2/doc/Todo.txt new file mode 100644 index 000000000000..6520abaa10a8 --- /dev/null +++ b/sj2/doc/Todo.txt @@ -0,0 +1,108 @@ +Erkenntnisse aus sj/sj1, die in sj2 beachtet werden mssen + + +- Call von C++ +"javascript: ..." nicht wie event behandeln, insbesondere werden +this und document nicht implizit als Search-Objekte gesetzt. + + +- prototype Eigenschaft von Objekten: +Manipuliert Klassen-Informationen, falls an einem beliebigen Objekt +eine Property mit gleichem Namen angelegt wird, so gilt dieses +Ueberschreiben jedoch nur fuer dieses eine Objekt !!! +Im Sj/Sj1 Projekt ist dies jedoch nicht erfuellt ! + +Beispiel: +function Ctor() { ... } + +obj1 = new Ctor(); // obj1 obj2 +obj2 = new Ctor(); //------------------------- +Ctor.prototype.toString = myToString; // myToString myToString +obj1.toString = myToString2; // myToString2 myToString +Ctor.prototype.toString = myToString3; // myToString2 myToString3 + + +- toString() und valueOf() Behandlung des BaseObj bei Type-Konversion + +======================================================================== + +Bemerkungen zur Suchreihenfolge und zum Ueberladen von Funktionen: + +* fuer jede 'Klasse' (z.B. Math, Date, String) gibt es ein Konstruktor- + Objekt in der JavaScript-Umgebung. + In dem Konstruktor-Objekt werden die Properties der Klasse angelegt, + z.B. sin, cos. + Der Konstruktor setzt seine Properties an jedem neu erzeugten + Objekt. Daher hat z.B. jedes Date-Objekt eine (default-behandelte) + Property setMonth. + Zum Setzten der Properties des Konstruktor an das neu erzeugte + Objekt sollte die initProp()-Methode noch einen Bereich der zu + kopierenden Properties bekommen, damit nicht alle nachtraeglich + am Konstruktor-Objekt angelegten Properties auch am Objekt gesetzt + werden. + +* jedes Objekt haelt eine Referenz auf seinen Konstruktor (entweder die + vordefinierten Klassen wie Math, Date oder die Funktion mit der das + Objekt erzeugt wurde). + +* fuer die Suchreihenfolge gibt es folgende drei Moeglichkeiten: + + - Default-behandelte Property: + aStrg = new String( "gulp" ); + aStrg.toString() // --> verwendet toString-Property am + // String-Konstruktor (default-Behandlung) + + - Default-Behandlung ueberladen am Konstruktor: + aStrg = new String( "gulp" ); + String.prototype.toString = myToString; // UEBERLADEN ! + aStrg.toString() // --> verwendet myToString-Funktion. + // Das prototype-Objekt wird am String-Ctor. + // angelegt und ueberschreibt daher die + // default-behandelte Property am Objekt !!! + // Der Interpreter muss dann noch an einem + // ggf. vorhandenen prototype-Objekt am + // Konstruktor nach der Property suchen. + + - ueberladen am Objekt: + aStrg = new String( "gulp" ); + String.prototype.toString = myToString; // am Ctor. ueberladen + aStrg.toString = myToString2; + aStrg.toString() // --> verwendet myToString2-Funktion. + // Die Property toString wird am Objekt + // ueberschrieben und somit das Flag, dass + // die default-Behandlung anzeigt, zurueck + // gesetzt. D.h. der Interpreter muss das + // prototype-Objekt des Konstruktors NICHT + // durchsuchen. + + +======================================================================== + +DEMNAECHST: + +Die Properties der Standard-Objekte (z.B. setSeconds() am Date) +werden am prototype-Objekt des Konstruktors (z.B. DateCtor) angelegt. +Bei der Suche nach Properties an einem beliebigen Objekt wird erst +das Objekt durchsucht und anschliessend das prototype-Objekt des +Konstruktors fuer das Objekt durchsucht. Dieses Verhalten gleicht +dem Netscape-Verhalten (Stand 2.7.1997). + +ACHTUNG, AB 11.8: +Das ist so nicht korrekt, da die entsprechenden Properties direkt +am prototype-Objekt nicht bekannt sind. Die an den Objekten als +Default geflagten Properties bilden daher das Netscape-Verhalten +besser ab. + + +======================================================================== + +WEITERE OFFENE PROBLEME: +------------------------ + + * this auf der Wiese funktioniert noch nicht korrekt + + * Konversion von Typen ? + + + + diff --git a/sj2/doc/concepts.html b/sj2/doc/concepts.html new file mode 100644 index 000000000000..49f336b131d8 --- /dev/null +++ b/sj2/doc/concepts.html @@ -0,0 +1,844 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<HTML> +<HEAD> + <TITLE></TITLE> + <META NAME="GENERATOR" CONTENT="StarOffice/4.0 (WinNT/Win95)"> + <META NAME="AUTHOR" CONTENT=" "> + <META NAME="CREATED" CONTENT="19970401;13233926"> + <META NAME="CHANGEDBY" CONTENT=" "> + <META NAME="CHANGED" CONTENT="19970529;8045806"> +</HEAD> +<BODY> +<H1>Stardivision erweiterte Java Grundkonzepte</H1> +<H2><A NAME="Exceptions"></A>Exceptions:</H2> +<P>Die Grundidee von Exceptions ist es einen Fehlerkontext +aufzuspannen, der erst näher betrachtet werden muß, wenn +man Fehler korrigieren will. Der Programmcode sollte durch die +Behandlung von Fehlern nicht undurchsichtig und unleserlich werden. +Meiner Meinung nach sollten Exceptions deswegen auch nicht als +zweiter Returnwert vergewaltigt werden.<BR><B>Ziel:</B> Nach dem +Auftreten einer Exception sollte es möglichst einfach sein das +System in einen definierten arbeitsfähigen Zustand zu +versetzen.<BR>Es gibt grundsätzlich drei verschiedenen Arten von +Exceptions. Diese unterscheiden sich durch den Zustand in dem sie das +Objekt hinterlassen.</P> +<OL> + <LI><P><A NAME="Undefined Exception"></A>Die von der Methode + benutzten Objekte sind in einem undefinierten Zustand. Jede auf dem + Objekt aufgerufene Methode muß nach einer solchen Exception + nicht mehr ihre Spezifikation einhalten. Diese Exception wird im + folgenden mit „Undefined Exception“ benannt. Dabei ist zu + beachten, daß keine weiteren <A HREF="#Resourcen">Resourcen</A>, + außer die angegebenen, benutzt werden. Außerdem werden + „ReadOnly“ Resourcen nicht modifiziert.</P> + <LI><P><A NAME="Defined Exception"></A>Die von der Methode benutzten + Objekte sind in einem genau definierten Zustand, der aber von der + Zusicherung der Methode abweicht. Diese Exception wird im folgenden + mit „Defined Exception“ benannt. Dabei ist zu beachten, + daß keine weiteren <A HREF="#Resourcen">Resourcen</A>, außer + die angegebenen, benutzt werden. Außerdem werden „ReadOnly“ + Resourcen nicht modifiziert.</P> + <LI><P><A NAME="Transacted Exception"></A>Die von der Methode + benutzten Objekte sind in ihrem vorherigen Zustand, der aber von der + Zusicherung der Methode abweicht. Diese Exception wird im folgenden + mit „Transacted Exception“ benannt. Dabei ist zu beachten, + daß keine weiteren <A HREF="#Resourcen">Resourcen</A>, außer + die angegebenen, benutzt werden. Außerdem werden „ReadOnly“ + Resourcen nicht modifiziert. Diese Spezifikation trifft auch auf + „Defined Exception“ zu, wegen ihrer Bedeutung führe + ich sie extra auf.</P> +</OL> +<P>Die Benutzbarkeit eines Objektes, nachdem eine Exception +aufgetreten ist, ist vom obigen Typ der Exception abhängig.</P> +<P><FONT COLOR="#ff0000">Satz 1.1: Nachdem eine „Undefined +Exception“ aufgetreten ist, kann mit dem Objekt sowie allen +„ReadWrite“ Resourcen nicht mehr weiter gearbeitet werden.</FONT></P> +<P><FONT COLOR="#ff0000">Satz 1.2: Nachdem eine „Defined +Exception“ aufgetreten ist, kann aufgrund des genau definierten +Zustandes weiter gearbeitet werden.</FONT></P> +<P><FONT COLOR="#ff0000">Satz 1.3: Nach einer „Transacted +Exception“ ist der gleiche Zustand wie vor dem Aufruf +wiederhergestellt.</FONT></P> +<P>Es sollten möglichst nur „Transacted Exception“ +ausgelöst werden. Bei komplizierten Methoden läßt +sich aber eine „Defined Exception“ nicht immer vermeiden. +Eine „Undefined Exception“ deutet immer auf eine +Programmierfehler hin. Der Typ der Exeption kann nur in Zusammenhang +mit der Methode in der sie Auftritt ermittelt werden.</P> +<P><FONT COLOR="#ff0000">Satz 1.4: Durch die Klasse der Exception +kann niemals alleine der Typ (undefined, defined oder transacted) +entschieden werden.</FONT></P> +<H2><A NAME="Resourcen"></A>Resourcen (under construction)</H2> +<P>Die Grundidee von Resourcen ist die Aufteilung eines Gebildes in +weitere Einheiten. Auf diesen können dann verschiedene Aufträge +gleichzeitig arbeiten, wenn sie nicht dieselben Resourcen benutzen. +Z.B. kann man in einer Textverarbeitung die einzelnen Dokumente als +Einheiten betrachten. Aufträge, die sich nur auf ein Dokument +beziehen, können parallel zu anderen Dokumenten bearbeitet +werden.<BR>Mit Resourcen sind im System bzw. der Applikation +vorhandene Objekte, Services, Kanäle ... gemeint, die zur Zeit +nur von einem Thread benutzt werden können. Als Konsequenz +müssen Resourcen einem Thread zugeordnet werden, bevor dieser +sie benutzt.<BR><B>Ziel:</B> Es muß möglich sein, 1. +Aufträge parallel abzuarbeiten, 2. die Frage „Warum können +zwei Aufträge nicht parallel arbeiten?“ beantwortet zu +können.<BR>Es gibt verschiedene Möglichkeiten diese +Zuordnung vorzunehmen. Zwei stelle ich kurz vor.</P> +<OL> + <LI><P><A NAME="Prealloc Resource Konzept"></A>Eine Art der + Zuordnung ist das vorherige Anfordern aller für den Auftrag + benötigten Resourcen. Ist dies möglich, kann der Auftrag + ohne weitere Störungen ablaufen. Die Resourcen dürfen + freigegeben werden, bevor der Auftrag beendet ist. Dies gilt + natürlich nur für nicht mehr verwendete Resourcen. Es darf + ebenfalls das Zuordnungsrecht von lesend und schreibend auf lesend + zurückgenommen werden. Diese Zuornungsart wird im weiteren mit + „Prealloc Resource Konzept“ bezeichnet.</P> + <LI><P><A NAME="Ondemand Resource Konzept"></A>Eine andere Art der + Zuordnung ist das Anfordern der Resourcen, wenn sie benötigt + werden. Dabei kann es zu Störungen kommen, wenn sich + verschiedene Aufträge um die gleiche Resource bewerben. Die + Resourcen dürfen freigegeben werden, bevor der Auftrag beendet + ist. Dies gilt natürlich nur für nicht mehr verwendete + Resourcen. Es darf ebenfalls das Zuordnungsrecht von lesend und + schreibend auf lesend zurückgenommen werden. Diese Zuornungsart + wird im weiteren mit „Ondemand Resource Konzept“ + bezeichnet.</P> +</OL> +<P>Es gibt noch weitere Möglichkeiten Aufträge zu +bearbeiten, die die gleichen Resourcen benutzen. Häufig findet +man solche Lösungen bei Datenbankanwendungen.<BR>In der +folgenden Tabelle stehen sich die beiden Konzepte mit ihren Vor- und +Nachteilen und ihren Anforderungen gegenüber.</P> +<TABLE WIDTH=100% BORDER=1 CELLPADDING=5 FRAME=BOX RULES=ALL> + <COLGROUP> + <COL WIDTH=85*> + <COL WIDTH=85*> + <COL WIDTH=85*> + </COLGROUP> + <THEAD> + <TR> + <TH WIDTH=33% VALIGN=TOP> + <P><BR></TH> + <TD WIDTH=33% VALIGN=TOP><DL> + <DD>Prealloc Resource Konzept </DD> + </DL> + </TD> + <TD WIDTH=33% VALIGN=TOP> + <DL> + <DD>Ondemand Resource Konzept </DD> + </DL> + </TD> + </TR> + </THEAD> + <TBODY> + <TR> + <TD VALIGN=TOP> + <P>Alle Resourcen müssen vor der Auftragsausführung + bekannt sein.</TD> + <TD VALIGN=TOP> + <P>Ja</TD> + <TD VALIGN=TOP> + <P>Nein</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P>Nicht mehr benötigte Resourcen dürfen freigegeben + werden.</TD> + <TD VALIGN=TOP> + <P>Ja</TD> + <TD VALIGN=TOP> + <P>Ja</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P>Es kann zu Verklemmungen oder „Races“ kommen.</TD> + <TD VALIGN=TOP> + <P>Nein</TD> + <TD VALIGN=TOP> + <P>Ja</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P>In Bearbeitung befindliche Aufträge müssen, aufgrund + fehlender Resourcen, abgebrochen werden.</TD> + <TD VALIGN=TOP> + <P>Nein</TD> + <TD VALIGN=TOP> + <P>Ja</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P>Der Zustand der Resourcen ist zu jedem Zeitpunkt der + Auftragsabarbeitung bekannt.</TD> + <TD VALIGN=TOP> + <P>Ja</TD> + <TD VALIGN=TOP> + <P>Nein</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P>Algorithmus zur Resourcevergabe.</TD> + <TD VALIGN=TOP> + <P>Einfach, da nur überprüft werden muß, ob alle + benötigten Resourcen verfügbar sind.</TD> + <TD VALIGN=TOP> + <P>Komplex, da neben dem Anfordern von Resourcen auch noch + überprüft werden muß, ob das System <A HREF="#lebendig">lebendig</A> + ist.</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P>Parallelität</TD> + <TD VALIGN=TOP> + <P>Hoch, da unabhängige Aufträge meistens nur lesend + auf gemeinsame Resourcen zugreifen.</TD> + <TD VALIGN=TOP> + <P>Sehr hoch, da die benötigten Resourcen erst angefordert + werden, wenn man sie braucht.</TD> + </TR> + </TBODY> +</TABLE> +<P ALIGN=LEFT>Meiner Meinung nach ist nur das „Prealloc Resource +Konzept“ ohne richtige Programmierwerkzeuge zur Entwicklung +paralleler Algorithmen (z.B. Netzprogrammierung) wenigstens ein +bißchen beherschbar.</P> +<P ALIGN=LEFT>Es stellt sich die Frage wie das „Prealloc +Resource Konzept“ in einem Komponenten-Modell und in einem +Objekt-Environment integriert werden kann. Ein Objekt-Environment ist +ein mehr oder weniger dynamische Menge von Objekten die miteinander +in Verbindung stehen. Aus dem obigen Beispiel könnte man die +Verbindung der Textverarbeitung zu ihren Dokumenten als +Objekt-Environment bezeichnen. Ein Objekt in diesem Environment kann +nun über seine Verbindungen mit anderen Objekten kommunizieren. +Die Schnittstellen mit denen über die Verbindung kommuniziert +wird nennt man Komponenten-Modell. Die Idee des Objekt-Environments +ist es weitere Objekte möglichst einfach zu integrieren. So +könnten in unserem Beispiel weitere Dokumenttypen wie ein +HTML-Dokument eingebunden werden. Die Schittstellen müßten +nur dem, von der Textverarbeitung geforderten, Komponenten-Modell +genügen. Liefert aber das Modell, wie heute üblich, keine +Information über die benötigten Resourcen bei Benutzung der +Schnittstellen, dann können Verklemmungen bzw. Inkonsistenzen +nicht vermieden werden. Aus diesem Grunde ist es notwendig, das +Resource-Konzept in das Komponenten-Modell zu integrieren.<BR><B>Ziel:</B> +Es muß ein Kompromiß zwischen hoher Nebenläufigkeit +und der damit verbundenen Komplexität, sowie einfacher +Programmierung und geringer Nebenläufigkeit gefunden +werden.<BR><B>Folgen:</B> In einem Objekt-Environment müssen die +einzelnen Objekte also dynamisch auf Verbindungen zu Objekten mit +hoher oder geringer Nebenläufigkeit reagieren. Die Komplexität +dieser Aufgabe darf aber nicht in die Objekte verlagert werden, da +von einem seriellen Objekt (bzw. dessen Programmierer) nicht die +Steuerung nebenläufiger Aufträge verlangt werden +kann.<BR><B>Lösungsansatz:</B> Die Behandlung der +Nebenläufigkeit wird nicht in einer einfachen Komponente +implementiert. Das bedeutet sie muß mit einer +Default-Behandlung zufrieden sein, die minimale Nebeläufigkeit +nach sich zieht. Eine Komponente kann sich aber in die Vergabe der +Resourcen einmischen. So kann sie ihren Grad der Nebenläufigkeit +erhöhen. Dies ist dann aber auch mit erhöhtem +Implementationsaufwand zu bezahlen. Auf der anderen Seite macht es +aber keinen Sinn serielle oder Komponenten mit zu großem +Resourcebedarf einzubinden, wenn das Objekt-Environment danach +praktisch nicht mehr lauffähig ist. Das bedeutet, daß das +Objekt-Environment auch Forderungen bezüglich des Resourcebedarf +an die Komponenten stellen darf.</P> +<H3>Anforderungen</H3> +<OL> + <LI><P ALIGN=LEFT>Es muß ein Modell geben, in dem alle + vorhandenen Resourcen und deren Beziehung zueinander eingetragen + werden. Dadurch kann abgeschätzt werden, welchen Resourcebedarf + eine Komponente hat. Das „Schätzen“ ist wörtlich + zu nehmen. (Im Zusammenhang mit <A HREF="#Security">Security</A> + wird man aber auch noch sehen, daß der Zugriff auf bestimmte + Resourcen nicht möglich ist.) Für das „Prealloc + Resource Konzept“ gilt, es müssen mindestens die + benötigten Resourcen verfügbar sein. Zur Not sind diese + alle.</P> + <LI><P ALIGN=LEFT>Eine nebenläufige Komponente muß in + jeder ihrer von außen erreichbaren Methoden kontrollieren, ob + die entsprechenden Resourcen für sie angefordert wurden. Damit + serielle Komponenten diese Methoden nutzen können, können + die benötigten Resourcen angefordert werden, wenn vorher noch + <B>keine einzige</B> durch den ausführenden Auftrag belegt war. + Zur Erläuterung: Serielle Komponenten belegen keine Resourcen. + Damit würde jeder Aufruf einer nebenläufigen Komponente + scheitern. Um dies zu vermeiden, werden die Resourcen in der + nebenläufigen Komponente angefordert.</P> + <LI><P ALIGN=LEFT>Serielle Komponenten müssen also damit + rechnen eine Fehlermeldung über nicht verfügbare Resourcen + zu bekommen.</P> +</OL> +<H3>Szenarien</H3> +<P>Von unserem bisherigen Beispiel ausgehend, gibt es eine +Applikation in der sich drei Dokumente befinden. Ein serielles +Textdokument, ein nebenläufiges Tabellendokument und ein +nebenläufiges Präsentationsdokument. Die Applikation selbst +ist nebenläufig. Die Relationen gehen von der Applikation zu den +Dokumenten und umgekehrt. Die Dokumente kennen sich nicht.</P> +<P>Fall 1:<BR>In das serielle Textdokument soll eine Zeichenfolge +eingefügt werden. Da es sich um eine serielle Komponente +handelt, kann dieses Einfügen nicht von selbst ausgelöst +werden, es muß von einer nebenläufigen Komponente, hier +die Applikation, angestoßen werden. Die Applikation ist aber +verpflichtet die Resourcen vorher zu reservieren. Für diese +Abschätzung gibt es drei realistische Möglichkeiten. 1. Sie +reserviert nur das Textdokument selbst. Das bedeutet, das +Textdokument kann mit keinem anderen Objekt, auch nicht mit der +Applikation, kommunizieren. 2. Die Applikation und das Textdokument +wird reserviert. Es ist also nur der Zugriff auf die anderen +Dokumente verwehrt. 3. Alle Objekte werden reserviert. Geht es nach +dem „Prealloc Resource Konzept“ muß 3. gewählt +werden. Aufgrund von Sicherheitsbeschränkungen werden wir aber +noch sehen, das serielle Komponenten in ihrer Auftragsbearbeitung +gestoppt werden können. Wenn der Abbruch eines Auftrags möglich +ist, spielt es aber keine Rolle durch wen (Resourcen oder <A HREF="#Security">Security</A>) +dies geschehen ist.</P> +<P>Fall 2:<BR>In das nebenläufige Tabellendokument soll eine +Zeichenfolge eingefügt werden. Dieser Auftrag kann von der +Applikation oder der Komponente selbst ausgelöst werden. In +jedem Fall müssen die Resourcen vor der Auftragsbearbeitung +reserviert werden. Man kann dies auch der Komponente überlassen +(siehe Anforderung 2.), aber man scheitert, wenn zwei Aufträge +zu einem Auftrag zusammengefaßt werden sollen. Dies passiert +z.B., wenn der Auftrag „Text ersetzen“ aus den Aufträgen +„Löschen“ und „Einfügen“ besteht. Auf +jeden Fall wird nur das Tabellendokument selbst reserviert, da das +Einfügen keine Auswirkung auf andere Komponenten hat.</P> +<P>Fall 3:<BR>In das nebenläufige Tabellendokument wird der +Applikationsname aus der Applikation eingefügt. Dazu fragt das +Tabellendokument nach den benötigten Resourcen, um den Namen zu +holen und ihn einzufügen. Zum Holen wird die Applikation +benötigt und zum Einfügen das Tabellendokument. Beide +müssen vor der Auftragsausführung reserviert werden.</P> +<P>Fall 4:<BR>Das nebenläufige Tabellendokument fügt +selektierten Text aus dem seriellen Textdokument ein. Da das +Textdokument seinen Resourcebedarf nicht mitteilt, wird einer aus +Fall eins abgeschätzte Bedarf genommen. Man kann sehen, daß +der Auftrag für alle drei Möglichkeiten erteilt werden +kann. Seine Nebenläufigkeit wird dann durch die Abschätzung +eingeschränkt. Zusätzlich müssen natürlich die +benötigten Resourcen für das Einfügen geholt werden. +Alle müssen vor der Auftragsausführung reserviert werden.</P> +<H3>Programmierkonzepte</H3> +<P>Welche Konzepte können in einer objektorientierten Sprache +wie c++ oder Java oder einer prozeduralen Sprache wie Fortran oder +„c“ eingesetzt werden, um Nebenläufigkeit zu +erreichen. </P> +<OL> + <LI><P>Es gibt zwei Möglichkeiten eine Resource zu belegen. Das + ist Exclusive (lesen, schreiben) und „ReadOnly“. Eine + Resource kann von mehreren Aufträgen benutzt werden, wenn diese + nur „ReadOnly“ benötigen.</P> + <LI><P>Es gibt Resourcen für die man die Resourceverteilung + optimieren kann. Ein Objekt welches nicht geändert werden kann + und das während der Auftragsausführung immer konsistent + ist kann die Anforderung „Exclusiv“ automatisch auf + „ReadOnly“ abschwächen. Dies lohnt sich, wenn man + serielle Komponenten hat, die nichts über die + Resourceanforderungen mitteilen. Als Beispiel möchte ich eine + Instanz der Klasse String in Java nennen. Ein weitere Art von + Resourcen fordern bei Aufträgen an sie 1. keine weiteren + Aufträge an, 2. beenden sie die Aufträge schnell und 3. + die Reihenfolge der Änderung an ihnen ist für andere nicht + wichtig. Dies ist zum Beispiel bei der Speicherverwaltung in c der + Fall. Diese Art der Resource darf zu einem späteren Zeitpunkt + angefordert werden. Sie muß sofort benutzt und wieder + freigegeben werden. Aus diesem Grund erledigen solche Resourcen das + Anfordern und Freigeben selbst.</P> + <LI><P>Bevor ein Auftrag ausgeführt werden kann, müssen + alle von ihm benötigten Resourcen reserviert werden. Dies ist + für einen Auftrag, der aus mehreren Teilaufträgen besteht, + aufwendig. Eine Optimierung kann darin bestehen die Teilaufträge + asynchron auszuführen. Allerdings dringt diese Verhaltensweise + nach außen. Z.B. müssen Aufträge, die diesen dann + asynchronen Auftrag nutzen, dann auch asynchron sein. Eine weitere + Optimierung in der Autragsvergabe gibt es, wenn ein Autrag die + Resourcervergabe nicht ändert. Es ist dann möglich mehr + Aufträge vorzuziehen.</P> + <LI><P>Es muß eine Queue geben, in die Aufträge eingefügt + werden können. Konfliktfreie Aufträge können parallel + ausgeführt werden. <B>Achtung:</B> Der Resourcebedarf eines + Auftrages kann nur bestimmt werden, wenn alle benötigten + Resourcen „ReadOnly“ reserviert werden können, es sei + denn kein vor ihm laufender Auftrag ändert die Resourcevergabe. + Warum ist das so? Ein Auftrag kann eine Resource dahingehend ändern, + daß danach andere Resourcen benötigt werden als vorher. + Der vorher bestimmte Bedarf ist dann falsch.</P> + <LI><P>Das Modell der Resourcen kann vergröbert oder verfeinert + werden. In einem Tabellendokument könnte man jede einzelne + Zelle zu einer Resource machen. Um die Komplexität der + Resourcemodells zu vereinfachen kann man aber weiter alle Zellen der + Dokument-Resource zuordnen. Wird also aus einer anderen Komponente + die Zelle angefordert, wird automatisch das ganze Dokument + reserviert. Daraus ergeben sich zwei Vorteile: 1. Für den + Auftraggeber ist die Vergröberung transparent und 2. Kann die + Resource an dem Objekt reserviert werden, das man ohnehin kennt.</P> + <LI><P>Das Resource-Modell ist hierarchisch. Eine Resource kann nur + einer Vergröberung zugeordnet werden. Die Tabellenzellen dürfen + also nur dem Tabellendokument zugeordnet werden. Daraus ergibt sich, + daß innerhalb einer solchen Hierarchie nebenläufig + gearbeitet werden kann. Es dürfen dann aber keine Resourcen + außerhalb der Hierarchie benutzt werden, selbst wenn diese + reserviert sind.</P> +</OL> +<H3>Probleme und Lösungen</H3> +<P>Über den Benutzer müssen Daten abgefragt werden, die +über die Benutzung von Resourcen entscheidet (z.B. +Dateiname):<BR>Ein solcher Auftrag muß in zwei Teilaufträge +unterteilt werden. Der erste erledigt die Abfrage. Danach werden alle +Resourcen freigegeben und dann fordert der zweite seine Resourcen und +wird bearbeitet. Eventuell kann ein solcher Auftrag den vorherigen +ersetzten, um zu verhindern das andere abhängige Aufträge +vor dem Aufgeteilten bearbeitet werden.</P> +<P>Ich habe mich bei einem Objekt als Listener angemeldet:<BR>Es gibt +zwei Arten von Benachrichtigungen die ich erhalte. 1. Aufgrund der +Ausführung eines Auftrages und 2. einen Event von einer +nebenläufigen Komponente. Im ersten Fall überprüfe ich +den Resourcebedarf und führe dann den Auftrag aus. Im zweiten +Fall reserviere ich die benötigten Resourcen und führen den +Auftrag aus. Sind Resourcen reserviert, ist dies Fall eins, sonst +Fall zwei.</P> +<P>Ich bin Broadcaster:<BR>Broadcaste ich aufgrund eines Auftrags tue +ich nichts weiter. Löse ich den Broadcast ohne Auftrag aus, muß +ich die Resourcen für die Listener bestimmen und sie vor dem +Aufruf reservieren. Die einzelnen Listener werden als unabhängig +betrachtet. Im Detail findet folgender Ablauf statt. 1. Die Liste der +Listener wird kopiert. 2. Für den ersten Listener wird der +Resourcebedarf ermittelt.</P> +<H3>Implementation</H3> +<P>Die Basis für die Implementation des Resourcekonzeptes legen +die Klassen <A HREF="stardiv.resource.Resource.html#Resource">Resource</A>, +<A HREF="stardiv.resource.ResourceList.html#ResourceList">ResourceList</A>, +<A HREF="stardiv.resource.ResourceLockException.html#ResourceLockException">ResourceLockException</A>, +<A HREF="stardiv.resource.Task.html#Task">Task</A>, <A HREF="stardiv.resource.TaskManager.html#TaskManager">TaskManager</A>, +<A HREF="stardiv.resource.TaskThread.html#Task">TaskThread</A>, +<A HREF="stardiv.resource.ThreadData.html#ThreadData">ThreadData</A> +und das Interface <A HREF="stardiv.resource.Resourceable.html#Resourceable">Resourceable</A> +fest. Um ein Objekt in das Resourcekonzept einbinden zu können +sind folgende Schritte notwendig:<BR>1. Das Resourceable Interface +muß implementiert werden. 2. Ein Konstruktor mit der dem +Objekte zugewiesenen Resource. 3. Jede public Methode bekommt eine +*_Resource(...) Methode zur Seite, mit der der Resourcebedarf +ermittelt werden kann. 4. Innerhalb der public Methode wird der +Resourcebedarf ermittelt. 5. Mit dieser Information die als +ResourceListe vorliegt, wird eine Auftrag (Task) erzeugt. 6. Dieser +Auftrag wird beim TaskManager angemeldet. 7. Nach der Zuteilung durch +den TaskManager wird der Auftrag ausgeführt. 8. Alle Resourcen +und der Auftrag werden wieder freigegeben.<BR>Diese Liste ist +detailliert aber nicht <B>vollständig</B>. In der Klasse +Resource steht imm eine Beispiel, welches aktuell sein sollte.</P> +<P>Folgende Programmierrichtlinien gibt es, um das „Prealloc +Resource Konzept“ in Java zu integrieren:</P> +<OL> + <LI><P ALIGN=LEFT>Es muß das Interface <A HREF="stardiv.resource.Resourceable.html#Resourceable">Resourceable</A> + implementiert werden. Mit Hilfe dieses Interfaces kann der + Resourcebedarf eines Objektes erfragt werden. Diese Richtlinien + gelten dann auch für die Superklasse.</P> + <LI><P ALIGN=LEFT>???Es muß das Interface <A HREF="stardiv.concepts.ModifyTestable.html#ModifyTestable">ModifyTestable</A> + implementiert werden. Damit kann überprüft werden, ob an + den Resourcen Veränderungen vorgenommen wurden.</P> + <LI><P ALIGN=LEFT>Nur Methoden die über die Lebensdauer des + Objektes keine veränderten Werte liefern dürfen immer + gerufen werden. Das sind zum Beispiel alle Methoden der Klasse + java.lang.Object.</P> + <LI><P ALIGN=LEFT>Um den Resourcebedarf einzelner Methoden genauer + zu ermitteln kann eine Methode mit dem, um _Resource( ResourceList + aRL, boolean bCheck, ... ) erweiterten Namen, gerufen werden. Ein + Beispiel befindet sich in der Klasse <A HREF="stardiv.resource.Resource.html#Resource">Resource</A>.</P> +</OL> +<H2><A NAME="Security"></A>Security</H2> +<H2><A NAME="Data Requests"></A>Data Requests</H2> +<P>Diese Schnittstelle soll das Anfordern von Daten vereinheitlichen. +Das Problem, welches zu diesem Ansatz führte, ist das Lesen von +Daten über einen „langsamen“ Internet-Stream. Das +bedeutet es werden Daten benötigt, die erst noch übertragen +werden müssen. Da das Pull-Modell immer einen eigenen Thread +vorraussetzt, um die restliche Anwendung nicht zu blockieren, habe +ich das Push-Modell gewählt.<BR><B>Ziel:</B> Für die +Implementation sollte es möglichst transparent sein, wie die +Daten herangeschafft werden. Als zweites soll die Schnittstelle für +denjenigen einfach sein, der alle Daten sofort bereithält.<BR><B>Lösung:</B> +Der Datenverarbeiter ist passiv. Das bedeutet, beim Entgegennehmen +der Daten beginnt er nicht sie zu verarbeiten. Dies muß extra +angestoßen werden. Zweitens, der Datenverarbeiter hält den +Status des Datenlieferanten. Dies können EOF, für alle +Daten gelesen, READY, für sind Daten da, PENDING, es kommen noch +weitere Daten und NO_SOURCE, es wurden nicht alle Daten verarbeitet +und es kommen keine weiteren Daten mehr. <B>Achtung</B> der Status +ist nur zu bestimmten Zeitpunkten gültig. Der Datenverarbeiter +darf nur im Zustand PENDING Daten bekommen. Diese Annahme schützt +ihn vor der Implementation eines Puffers. Das <A HREF="stardiv.concepts.QueryData.html#QueryData">QueryData</A> +- Interface ist die Spezifikation für dieses Verhalten.</P> +<H2><A NAME="Modify"></A>Modify</H2> +<P>Das Ziel ist nur eine Schnittstelle zu erstellen, mit der ein +Objekt auf Änderungen überprüft werden kann. Da es für +ein Objekt verschiedene Möglichkeiten gibt Änderungen an +sich zu prüfen (z.B. Änderungszähler, Kopie), muß +die Schnittstelle möglichst flexibel sein, um vielen +Implementationen gerecht zu werden. Die Lösung sind zwei +Methoden. Mit der einen (getModifyHandle()) kann der Zeitpunkt +festgemacht werden, zu dem mögliche Änderungen überprüft +werden sollen. Der Rückgabewert ist eine beliebiges Objekt, so +daß in ihm die benötigte Überprüfungsinformation +(z.B. der Änderungszähler) untergebracht werden kann. +Danach kann mit der zweiten Methode (isModified(Object)) überprüft +werden, ob eine Änderung stattgefunden hat. Das Interface für +dieses Konzept heißt <A HREF="stardiv.concepts.ModifyTestable.html#ModifyTestable">ModifyTestable</A> +.</P> +<H2><A NAME="LifeConnect"></A>LifeConnect</H2> +<P>LifeConnect ist die Kommunikation zwischen PlugIns, Applets und +JavaScript. Die Kommunikation kann in beide Richtungen erfolgen.Unter +JavaScript kann auf alle Systemklassen zugegriffen werden. Die +Abbildung der JavaScript-Aufrufe nach Java ist die Aufgabe der Klasse +<A HREF="stardiv.js.ip.CallJava.html#CallJava">CallJava</A>. Dazu +wird das in Java 1.1 implementierte Package java.lang.reflect +benutzt. Da JavaScript eine nicht typisierte Sprache ist, werden die +Werte nach JavaScript-Regeln in die entsprechenden Javatypen +umgesetzt. Bezüglich der Sicherheit wird ein JavaScript-Programm +auf die gleiche Stufe wie ein Applet gestellt. Um den Zugriff der +Applets auf JavaScript zu gestatten, muß das HTML-Tag MYSCRIPT +angegeben werden. Auf die Java-Klassen kann in JavaScript mit dem +Prefix „Package“ zugegriffen werden (sun, java und netscape +benötigen keinen Prefix). Die Klassen netscape.plugin.Plugin, +netscape.javascript.JSObject und netscape.javascript.JSException +dienen zur Kommunikation von Java mit JavaScript.</P> +<P>Konvertierungstabelle anhand der Spezifikation „JavaScript +Language Specifications“ 3.1.2 TypeConversion</P> +<TABLE WIDTH=100% BORDER=1 CELLPADDING=5 CELLSPACING=0 FRAME=HSIDES RULES=ALL> + <COLGROUP> + <COL WIDTH=26*> + <COL WIDTH=40*> + <COL WIDTH=47*> + <COL WIDTH=47*> + <COL WIDTH=47*> + <COL WIDTH=47*> + </COLGROUP> + <THEAD> + <TR> + <TH WIDTH=10% VALIGN=TOP> + <P><BR></TH> + <TH WIDTH=16% VALIGN=TOP> + <P><I>byte</I></TH> + <TH WIDTH=19% VALIGN=TOP> + <P><I>short</I></TH> + <TH WIDTH=19% VALIGN=TOP> + <P><I>char</I></TH> + <TH WIDTH=19% VALIGN=TOP> + <P><I>int</I></TH> + <TH WIDTH=19% VALIGN=TOP> + <P><I>long</I></TH> + </TR> + </THEAD> + <TBODY> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Undef.</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Fehler</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Fehler</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Fehler</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Fehler</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Fehler</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Function</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(10) valueOf/error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(11) valueOf/error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(11) valueOf/error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(12) valueOf/error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(13) valueOf/error</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Object</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(10) valueOf/error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(11) valueOf/error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(11) valueOf/error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(12) valueOf/error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(13) valueOf/error</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Object (null)</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(10) 0</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(11) 0</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(11) 0</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(12) 0</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(13) 0</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>double</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(10) Zahl oder Fehler, wenn Bereichs-überschreitung</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(11) Zahl oder Fehler, wenn Bereichs-überschreitung</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(11) Zahl oder Fehler, wenn Bereichs-überschreitung</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(12) Zahl oder Fehler, wenn Bereichs-überschreitung</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(13) Zahl oder Fehler, wenn Bereichs-überschreitung</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>boolean</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) 0/1</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) 0/1</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) 0/1</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) 0/1</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) 0/1</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Leer String</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>error</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>String</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(10) error/ Zahl</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(11) error/ Zahl</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(11) error/ Zahl</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(12) error/ Zahl</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(13) error/ Zahl</TD> + </TR> + </TBODY> +</TABLE><DL> + <DT><BR></DT> +</DL> +<TABLE WIDTH=100% BORDER=1 CELLPADDING=5 CELLSPACING=0 FRAME=BOX RULES=ALL> + <COLGROUP> + <COL WIDTH=27*> + <COL WIDTH=59*> + <COL WIDTH=44*> + <COL WIDTH=35*> + <COL WIDTH=36*> + <COL WIDTH=55*> + </COLGROUP> + <THEAD> + <TR> + <TH WIDTH=10% VALIGN=TOP> + <P><BR></TH> + <TH WIDTH=23% VALIGN=TOP> + <P><I>float</I></TH> + <TH WIDTH=17% VALIGN=TOP> + <P><I>double</I></TH> + <TH WIDTH=14% VALIGN=TOP> + <P><I>boolean</I></TH> + <TH WIDTH=14% VALIGN=TOP> + <P><I>String</I></TH> + <TH WIDTH=22% VALIGN=TOP> + <P><I>Object</I></TH> + </TR> + </THEAD> + <TBODY> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Undef.</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Fehler</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Fehler</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>false</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>„undefined“</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>null</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Function</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(14) valueOf/error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) valueOf/error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) valueOf/ true</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) JS-Code der Funktion</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(30) netscape .javascript. JSObject</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Object</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(14) valueOf/error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) valueOf/error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) valueOf/ true</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) valueOf / toString + </TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(30) Java-Cast/ error</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Object (null)</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(14) 0</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) 0</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) false</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) „null“</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(30) null</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>double</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(14) Zahl oder Fehler, wenn Bereichs-überschreitung</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(30) Zahl</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(7) 0, NaN -> false !0, -+Infinite -> true</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(8) Zahl, NaN, Infinity oder -Infinity</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(9) Number/ error + </TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>boolean</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) 0/1</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) 0/1</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(30) boolean</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) „false“/ “true“</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) Boolean/ error</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>Leer String</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>error</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) false</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(30) String</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) String/ error</TD> + </TR> + <TR> + <TD VALIGN=TOP> + <P ALIGN=LEFT>String</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(14) error/ Zahl</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) error/ Zahl</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) true</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(30) String</TD> + <TD VALIGN=TOP> + <P ALIGN=LEFT>(15) String/ error</TD> + </TR> + </TBODY> +</TABLE> +<P><BR></P> +<P>Der Algorithmus zum mappen der polymorphen Methoden in Java:<BR>1. +Die Anzahl der Parameter muß übereinstimmen.<BR>2. Die +Parameter müssen, nach der obigen Tabelle, konvertiert werden +können.<BR>3. Es gibt ein Punktesystem, nach dem die Methode +ausgewählt wird. Die Punkte stehen in Klammern in den +Tabelleneinträgen. Die Konvertierungspunkte für Zahlen sind +typabhängig und nicht wertabhängig. Dadurch ist +sichergestellt, das nicht unterschiedliche Methoden bei sich +ändernden Werten gerufen werden. Kommt es allerdings zu einem +Konvertierungsfehler (Überlauf), dann wird versucht eine andere +Methode zu finden.<BR>4. Es wird vorausgesetzt, daß die +Methoden „valueOf“ und „toString“ keine +Seiteneffekte haben. Sie dürfen also beliebig oft aufgerufen +werden.<BR>5. Es wird nur null auf eine Java-Array abgebildet.</P> +<H2><A NAME="Testen"></A>Testen</H2> +<P>Das Ziel dieses Abschnitts ist es Vorgehensweisen zu entwickeln, +mit denen sich die Java Grundkonzepte testen lassen. Folgende +Checkliste ist für jede Methode abzuarbeiten.</P> +<OL> + <LI><P>Zu jeder Klasse gibt es eine entsprechende Testklasse. Diese + steht im Package „test“.... Der Name der Klasse wird mit + „Test“ erweitert. Beispiel: stardiv.memory.BitArray wird + zu test.memory.BitArrayTest. Jede dieser Klassen hat eine Methode + „public static void main( String [] )“. Diese Methode wird + aufgerufen, um den Test aller Methoden anzustoßen. Der Test + ist nicht interaktiv. Wird ein Fehler festgestellt, wird das + Programm mit exit( -1 ) verlassen.</P> + <LI><P>Jede Methode muß unabhängig von ihren Environment + getestet werden. Alle Resourcen für die Methode werden als + Dummy für den Test implementiert. Diese Forderung führt zu + sauberen Schnittstellen, da ansonsten für den Test ja ganze + Objekte implementiert werden müssen.</P> + <LI><P>Das Testprotokoll protokolliert mit „System.out.println“. + Vor dem Test der einzelnen Methoden wird in einer Zeile kurz über + den Test informiert. Scheitert der Test, dann wird eine + Fehlermeldung ausgegeben in der „failed“ enthalten sein + muß. </P> + <LI><P>Um <A HREF="#Defined Exception">Defined Exception</A> und + <A HREF="#Transacted Exception">Transacted Exception</A> testen zu + können, sollten die <A HREF="stardiv.concepts.Resource.html#Resource">Resource</A> + und <A HREF="stardiv.concepts.ModifyTestable.html#ModifyTestable">ModifyTestable</A> + Interfaces implementiert werden. Es kann damit automatisch geprüft + werden, ob sich eine Resource unerlaubter Weise geändert hat.</P> +</OL> +<H2>Begriffe</H2> +<P><A NAME="lebendig"></A>Lebendig: Ein System wird als lebendig +bezeichnet, wenn alle in ihm befindlichen Aufträge +fertiggestellt werden können. Sie sich also nicht in einer +Verklemmung oder einem „Race“ befinden.</P> +</BODY> +</HTML>
\ No newline at end of file diff --git a/sj2/inc/sjapplet.hxx b/sj2/inc/sjapplet.hxx new file mode 100644 index 000000000000..6f7a5ec7012a --- /dev/null +++ b/sj2/inc/sjapplet.hxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * $RCSfile: sjapplet.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:02 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SJ_SJAPPLET_HXX +#define _SJ_SJAPPLET_HXX + +#include <tools/string.hxx> + +// ************************************************************** +//class stardiv_applet_AppletViewerPanel; +// class stardiv_applet_AppletExecutionContext; +// class java_awt_Frame; +// class com_sun_star_comp_jawt_peer_EmbeddedFrame; +// class java_awt_Window; +// class XubString; +// class SjJSbxObject; + +//#include <jni.h> + +class INetURLObject; +class Size; +class SjJScriptAppletObject; +class SvCommandList; +class Window; + +struct SjApplet2ImplStruct; + +enum SjNetAccess +{ + NET_UNRESTRICTED, NET_NONE, NET_HOST +}; + +class SjApplet2 +{ + Window * _pParentWin; + SjApplet2ImplStruct * _pImpl; + +public: + static void settingsChanged(void); + + SjApplet2(); + ~SjApplet2(); + void Init(Window * pParentWin, const INetURLObject & rDocBase, const SvCommandList & rCmdList); + void setSizePixel( const Size & ); + void appletRestart(); + void appletReload(); + void appletStart(); + void appletStop(); + void appletClose(); + + // Fuer SO3, Wrapper fuer Applet liefern + SjJScriptAppletObject * GetJScriptApplet(); + + virtual void appletResize( const Size & ) = 0; + virtual void showDocument( const INetURLObject &, const XubString & ) = 0; + virtual void showStatus( const XubString & ) = 0; +// virtual SjJSbxObject * getJScriptWindowObj() = 0; +}; + + + +#endif // _REF_HXX diff --git a/sj2/prj/d.lst b/sj2/prj/d.lst new file mode 100644 index 000000000000..e0246462b8b8 --- /dev/null +++ b/sj2/prj/d.lst @@ -0,0 +1,15 @@ +dos: mkdir %_DEST%\inc%_EXT%\sj2 +..\%__SRC%\class\classes.jar %_DEST%\bin%_EXT%\classes.jar +hedabu: ..\inc\sjapplet.hxx %_DEST%\inc%_EXT%\sj2\sjapplet.hxx + +..\%__SRC%\lib\sj.lib %_DEST%\lib%_EXT%\sj.lib +..\%__SRC%\lib\*.so %_DEST%\lib%_EXT%\*.so +..\%__SRC%\slb\sj.lib %_DEST%\lib%_EXT%\xsj.lib +..\%__SRC%\bin\j%UPD%*_g.dll %_DEST%\bin%_EXT%\j%UPD%*_g.dll + +dos: if "%GUI%" == "WIN" attrib -r %_DEST%\bin%_EXT%\sj%UPD%*.map +dos: if "%GUI%" == "WIN" copy ..\%__SRC%\misc\sj%UPD%*.map %_DEST%\bin%_EXT%\sj2%UPD%*.map +dos: if "%GUI%" == "WIN" attrib +r %_DEST%\bin%_EXT%\sj2%UPD%*.map +dos: if "%GUI%" == "OS2" attrib -r %_DEST%\bin%_EXT%\sj2%UPD%*.map +dos: if "%GUI%" == "OS2" copy ..\%__SRC%\misc\sj%UPD%*.map %_DEST%\bin%_EXT%\sj2%UPD%*.map +dos: if "%GUI%" == "OS2" attrib +r %_DEST%\bin%_EXT%\sj2%UPD%*.map diff --git a/sj2/source/inc/java_lang_object.hxx b/sj2/source/inc/java_lang_object.hxx new file mode 100644 index 000000000000..b9c39252aeba --- /dev/null +++ b/sj2/source/inc/java_lang_object.hxx @@ -0,0 +1,125 @@ +/************************************************************************* + * + * $RCSfile: java_lang_object.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include <jni.h> +#ifdef OS2 +#include <typedefs.h> +#endif + +#ifndef _SJ_JAVA_LANG_OBJECT_HXX +#define _SJ_JAVA_LANG_OBJECT_HXX + +#include <tools/string.hxx> + + +#ifdef HAVE_64BIT_POINTERS +#error "no 64 bit pointer" +#else +#ifdef OS2 +#define INT64_TO_PVOID(x) (void *)x.lo +inline jlong Make_Os2_Int64( INT32 hi, INT32 lo ) {jlong x = CONST64( hi, lo ); return x; } +#define PVOID_TO_INT64(x) Make_Os2_Int64( 0, (INT32)x ) +#else //OS2 +#define PVOID_TO_INT64(x) (jlong)(INT32)x +#define INT64_TO_PVOID(x) (void *)x +#endif //Os2 +#endif + +//===================================================================== +class java_lang_Class; +class java_lang_Object +{ + // Zuweisungsoperator und Copy Konstruktor sind verboten + java_lang_Object& operator = (java_lang_Object&) { return *this;}; + java_lang_Object(java_lang_Object&) {}; + + static jclass getMyClass(); + // nur zum Zerstoeren des C++ Pointers in vom JSbxObject + // abgeleiteten Java Objekten + //static jclass getJSbxObjectClass(); + +protected: + // der JAVA Handle zu dieser Klasse + jobject object; + // Klassendefinition + + // neu in SJ2: + static jclass theClass; // die Klasse braucht nur einmal angefordert werden ! + static jclass theJSbxObjectClass; // die Klasse braucht nur einmal angefordert werden ! + static ULONG nObjCount; // Zaehler fuer die Anzahl der Instanzen + +public: + // der Konstruktor, der fuer die abgeleiteten Klassen verwendet + // werden soll. + java_lang_Object( JNIEnv * pEnv, jobject myObj ); + // der eigentliche Konstruktor + java_lang_Object(); + + virtual ~java_lang_Object(); + + void saveRef( JNIEnv * pEnv, jobject myObj ); + jobject getJavaObject() const { return object; } + java_lang_Object * GetWrapper() { return this; } + + java_lang_Class * getClass(); + +}; + +#endif diff --git a/sj2/source/jscpp/makefile.mk b/sj2/source/jscpp/makefile.mk new file mode 100644 index 000000000000..9b2d65e9ea44 --- /dev/null +++ b/sj2/source/jscpp/makefile.mk @@ -0,0 +1,103 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=sj2 +TARGET=jscpp +# --- Settings ----------------------------------------------------- + +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb +UNOUCROUT=$(OUT)$/inc + +# --- Files -------------------------------------------------------- + +UNOTYPES= \ + com.sun.star.uno.Exception \ + com.sun.star.uno.XInterface \ + com.sun.star.uno.TypeClass \ + com.sun.star.awt.XControl \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.java.XJavaVM \ + com.sun.star.java.XJavaThreadRegister_11 + + +CXXFILES= \ + sjapplet.cxx \ + + +SLOFILES= \ + $(SLO)$/sjapplet.obj \ + +# .IF "$(GUI)"=="WNT" +# SLOFILES += $(SLO)$/sun_awt_windows_package.obj +# .ENDIF + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +.INCLUDE : $(PRJ)$/util$/target.pmk + diff --git a/sj2/source/jscpp/sjapplet.cxx b/sj2/source/jscpp/sjapplet.cxx new file mode 100644 index 000000000000..2df01d049958 --- /dev/null +++ b/sj2/source/jscpp/sjapplet.cxx @@ -0,0 +1,601 @@ +/************************************************************************* + * + * $RCSfile: sjapplet.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <jnihelp.hxx> + +#include <sjapplet.hxx> + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +#include <unotools/processfactory.hxx> +#include <rtl/ustring> + +#include <rtl/process.h> + +#include <jni.h> + +using namespace ::rtl; +using namespace ::com::sun::star::lang; +using namespace ::utl; + +#include <tools/urlobj.hxx> +#include <tools/debug.hxx> +#include <svtools/ownlist.hxx> +#include <vcl/svapp.hxx> +#include <vcl/window.hxx> +#include <vcl/wrkwin.hxx> +#include <vcl/syschild.hxx> + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::java; +using namespace ::sj2; + +#include <com/sun/star/java/XJavaVM.hpp> + +struct SjApplet2ImplStruct { + JavaVM * _pJVM; + jobject _joAppletExecutionContext; + jobject _joFrame; + jclass _jcAppletExecutionContext; + + Reference<XJavaVM> _xJavaVM; + Reference<XJavaThreadRegister_11> _xJavaThreadRegister_11; +}; + +SjApplet2::SjApplet2() + : _pParentWin(NULL), + _pImpl( new SjApplet2ImplStruct() ) +{ +} + +SjApplet2::~SjApplet2() +{ + if (_pImpl->_joAppletExecutionContext) + { + TKTThreadAttach jenv( _pImpl->_pJVM, + _pImpl->_xJavaThreadRegister_11.get() + ); + + jenv.pEnv->DeleteGlobalRef( _pImpl->_joAppletExecutionContext ); + jenv.pEnv->DeleteGlobalRef( _pImpl->_joFrame ); + jenv.pEnv->DeleteGlobalRef( _pImpl->_jcAppletExecutionContext ); + } + + delete _pImpl; +} + +//========================================================================= +void SjApplet2::Init( Window * pParentWin, const INetURLObject & rDocBase, const SvCommandList & rCmdList ) +{ + Reference<XMultiServiceFactory> serviceManager(getProcessServiceFactory()); + + _pImpl->_xJavaVM = Reference<XJavaVM> (serviceManager->createInstance(OUString::createFromAscii("com.sun.star.java.JavaVirtualMachine")), UNO_QUERY); + _pImpl->_xJavaThreadRegister_11 = Reference<XJavaThreadRegister_11>(_pImpl->_xJavaVM, UNO_QUERY); + + Sequence<sal_Int8> processID(16); + rtl_getGlobalProcessId((sal_uInt8 *)processID.getArray()); + Any aVMPtr = _pImpl->_xJavaVM->getJavaVM(processID); + if( sizeof( _pImpl->_pJVM ) == sizeof( sal_Int32 ) ) + { + // 32 bit system + sal_Int32 nP = 0; + aVMPtr >>= nP; + _pImpl->_pJVM = (JavaVM*)nP; + } + else if( sizeof( _pImpl->_pJVM ) == sizeof( sal_Int64 ) ) + { + // 64 bit system + sal_Int64 nP = 0; + aVMPtr >>= nP; + _pImpl->_pJVM = (JavaVM*)nP; + } + + TKTThreadAttach jenv(_pImpl->_pJVM, _pImpl->_xJavaThreadRegister_11.get()); + + // Java URL erzeugen + String aURL = rDocBase.GetMainURL(); + if ( aURL.Len() ) + { + //WorkAround, weil Java mit dem | nicht zurecht kommt + if( rDocBase.GetProtocol() == INET_PROT_FILE + && aURL.GetChar( (xub_StrLen)9 ) == INET_ENC_DELIM_TOKEN ) + aURL = aURL.Insert( INET_DELIM_TOKEN, (xub_StrLen)9 ); + } + + jclass jcURL = jenv.pEnv->FindClass("java/net/URL"); + jmethodID jmURL_rinit = jenv.pEnv->GetMethodID(jcURL, "<init>", "(Ljava/lang/String;)V"); + jobject joDocBase = jenv.pEnv->AllocObject(jcURL); + jstring jsURL = jenv.pEnv->NewString( aURL.GetBuffer(), aURL.Len() ); + jenv.pEnv->CallVoidMethod(joDocBase, jmURL_rinit, jsURL); + + jclass jcHashtable = jenv.pEnv->FindClass("java/util/Hashtable"); + jmethodID jmHashtable_rinit = jenv.pEnv->GetMethodID(jcHashtable, "<init>", "()V"); + jmethodID jmHashtable_put = jenv.pEnv->GetMethodID(jcHashtable, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); + jobject joParameters = jenv.pEnv->AllocObject(jcHashtable); + jenv.pEnv->CallVoidMethod(joParameters, jmHashtable_rinit); + + for( ULONG i = 0; i < rCmdList.Count(); i++ ) { + const SvCommand & rCmd = rCmdList[i]; + String aCmd = rCmd.GetCommand(); + String aLoweredCmd = aCmd.ToLowerAscii(); + jstring jsCommand = jenv.pEnv->NewString( aLoweredCmd.GetBuffer(), aLoweredCmd.Len() ); + jstring jsArg = jenv.pEnv->NewString( rCmd.GetArgument().GetBuffer(), rCmd.GetArgument().Len() ); + jenv.pEnv->CallVoidMethod(joParameters, jmHashtable_put, jsCommand, jsArg); + } + + + _pParentWin = pParentWin; + +#if defined(WNT) && defined(blblblblblblb) + if (WINDOW_SYSTEMCHILDWINDOW == pParentWin->GetType()) + { + const SystemChildData* pCD = ((SystemChildWindow*) pParentWin)->GetSystemData(); + if ( pCD ) + // hier wird das C++-Wrapper-Objekt fuer ein Java-Objekt erzeugt + pWindow = new sun_awt_windows_WEmbeddedFrame((INT32)pCD->hWnd); + } + if (!pWindow) + pWindow = new sun_awt_windows_WEmbeddedFrame(); +#else + jclass jcFrame = jenv.pEnv->FindClass("java/awt/Frame"); + jmethodID jmFrame_rinit = jenv.pEnv->GetMethodID(jcFrame, "<init>", "()V"); + _pImpl->_joFrame = jenv.pEnv->AllocObject(jcFrame); + _pImpl->_joFrame = jenv.pEnv->NewGlobalRef(_pImpl->_joFrame); + jenv.pEnv->CallVoidMethod(_pImpl->_joFrame, jmFrame_rinit); +#endif + + jmethodID jmFrame_show = jenv.pEnv->GetMethodID(jcFrame, "show", "()V"); + jenv.pEnv->CallVoidMethod(_pImpl->_joFrame, jmFrame_show); + + _pImpl->_jcAppletExecutionContext = jenv.pEnv->FindClass("stardiv/applet/AppletExecutionContext"); + _pImpl->_jcAppletExecutionContext = (jclass)jenv.pEnv->NewGlobalRef( _pImpl->_jcAppletExecutionContext ); + jmethodID jmAppletExecutionContext_rinit = jenv.pEnv->GetMethodID(_pImpl->_jcAppletExecutionContext, "<init>", "(Ljava/net/URL;Ljava/util/Hashtable;Ljava/awt/Container;J)V"); + jmethodID jmAppletExecutionContext_init = jenv.pEnv->GetMethodID(_pImpl->_jcAppletExecutionContext, "init", "()V"); + jmethodID jmAppletExecutionContext_startUp = jenv.pEnv->GetMethodID(_pImpl->_jcAppletExecutionContext, "startUp", "()V"); + + _pImpl->_joAppletExecutionContext = jenv.pEnv->AllocObject(_pImpl->_jcAppletExecutionContext); + _pImpl->_joAppletExecutionContext = jenv.pEnv->NewGlobalRef(_pImpl->_joAppletExecutionContext); + jenv.pEnv->CallVoidMethod(_pImpl->_joAppletExecutionContext, jmAppletExecutionContext_rinit, joDocBase, joParameters, _pImpl->_joFrame, (jlong)0); + jenv.pEnv->CallVoidMethod(_pImpl->_joAppletExecutionContext, jmAppletExecutionContext_init); + jenv.pEnv->CallVoidMethod(_pImpl->_joAppletExecutionContext, jmAppletExecutionContext_startUp); + +// pWindow->setVisible(TRUE); + +// pAppletExecutionContext = new stardiv_applet_AppletExecutionContext_Impl(&aDocBase, &aHashtable, pWindow, this); +// pAppletExecutionContext->init(); + +// pAppletExecutionContext->startUp(); +} + +//========================================================================= +void SjApplet2::setSizePixel( const Size & rSize ) +{ +// pWindow->setSize(rSize.Width(), rSize.Height()); +} + +void SjApplet2::appletRestart() +{ + TKTThreadAttach jenv(_pImpl->_pJVM, _pImpl->_xJavaThreadRegister_11.get()); + jmethodID jmAppletExecutionContext_restart = jenv.pEnv->GetMethodID(_pImpl->_jcAppletExecutionContext, "restart", "()V"); + jenv.pEnv->CallVoidMethod(_pImpl->_joAppletExecutionContext, jmAppletExecutionContext_restart); +} + +void SjApplet2::appletReload() +{ + TKTThreadAttach jenv(_pImpl->_pJVM, _pImpl->_xJavaThreadRegister_11.get()); + jmethodID jmAppletExecutionContext_reload = jenv.pEnv->GetMethodID(_pImpl->_jcAppletExecutionContext, "reload", "()V"); + jenv.pEnv->CallVoidMethod(_pImpl->_joAppletExecutionContext, jmAppletExecutionContext_reload); +} + +void SjApplet2::appletStart() +{ + TKTThreadAttach jenv(_pImpl->_pJVM, _pImpl->_xJavaThreadRegister_11.get()); + jmethodID jmAppletExecutionContext_sendStart = jenv.pEnv->GetMethodID(_pImpl->_jcAppletExecutionContext, "sendStart", "()V"); + jenv.pEnv->CallVoidMethod(_pImpl->_joAppletExecutionContext, jmAppletExecutionContext_sendStart); +} + +void SjApplet2::appletStop() +{ + TKTThreadAttach jenv(_pImpl->_pJVM, _pImpl->_xJavaThreadRegister_11.get()); + jmethodID jmAppletExecutionContext_sendStop = jenv.pEnv->GetMethodID(_pImpl->_jcAppletExecutionContext, "sendStop", "()V"); + jenv.pEnv->CallVoidMethod(_pImpl->_joAppletExecutionContext, jmAppletExecutionContext_sendStop); +} + +void SjApplet2::appletClose() +{ + if(_pImpl->_joAppletExecutionContext) + { + TKTThreadAttach jenv(_pImpl->_pJVM, _pImpl->_xJavaThreadRegister_11.get()); + jmethodID jmAppletExecutionContext_shutdown = jenv.pEnv->GetMethodID(_pImpl->_jcAppletExecutionContext, "shutdown", "()V"); + jenv.pEnv->CallVoidMethod(_pImpl->_joAppletExecutionContext, jmAppletExecutionContext_shutdown); + } + +// pWindow->dispose(); + + if( _pParentWin ) + { + WorkWindow* pAppWin = Application::GetAppWindow(); + if(pAppWin) + { + while(_pParentWin->GetChildCount()) + { + Window* pChild = _pParentWin->GetChild(0); + pChild->Show( FALSE ); + pChild->SetParent( pAppWin ); + } + } + } + +// delete pWindow; +// pWindow = NULL; +} + +// Fuer SO3, Wrapper fuer Applet liefern +SjJScriptAppletObject * SjApplet2::GetJScriptApplet() +{ + return NULL; +} + +#ifdef _OLD_FEATURE +class SjINetSettings : public ApplicationProperty +/* [Beschreibung] + + Diese Klasse repr"asentiert die Internet Einstellungen von Java. + Beim Initialisieren von Java werden, "uber die Methode + <Application::Property(...)>, die Einstellungen abgefragt. +*/ +{ + String aHttpProxy; + int nHttpProxyPort; + String aFtpProxy; + int nFtpProxyPort; + String aFirewallProxy; + int nFirewallProxyPort; +public: + TYPEINFO(); + SjINetSettings(); + + void SetHttpProxy( const String & rStr ) + { aHttpProxy = rStr; } + const String & GetHttpProxy() const { return aHttpProxy; } + void SetHttpProxyPort( int n ) + { nHttpProxyPort = n; } + int GetHttpProxyPort() const { return nHttpProxyPort; } + + void SetFtpProxy( const String & rStr ) + { aFtpProxy = rStr; } + const String & GetFtpProxy() const { return aFtpProxy; } + void SetFtpProxyPort( int n ) + { nFtpProxyPort = n; } + int GetFtpProxyPort() const { return nFtpProxyPort; } + + void SetFirewallProxy( const String & rStr ) + { aFirewallProxy = rStr; } + const String & GetFirewallProxy() const { return aFirewallProxy; } + void SetFirewallProxyPort( int n ) + { nFirewallProxyPort = n; } + int GetFirewallProxyPort() const { return nFirewallProxyPort; } +}; + +class SjJavaSettings : public ApplicationProperty +/* [Beschreibung] + + Diese Klasse repr"asentiert die allgemeinen Java Einstellungen. + Beim Initialisieren von Java werden, "uber die Methode + <Application::Property(...)>, die Einstellungen abgefragt. + + JavaHomeDir ist das Installationsverzeichnis von Java. +*/ +{ + String aClassPath; + String aJavaHomeDir; + SjNetAccess eNetAccess; + UINT32 nNativeStackSize; // Stack size for native threads + UINT32 nJavaStackSize; // Stack size for Java threads + UINT32 nMinHeapSize; // Minimum heap size (default 0 -> Java-Default) + UINT32 nMaxHeapSize; // Maximum heap size (default 0 -> JavaDefault) + + UINT32 nVerifyMode; // controls whether Java byte code should be verified: + // 0 -- none, + // 1 -- remotely loaded code, + // 2 -- all code. + + BOOL bEnableClassGC; // default set to TRUE + BOOL bEnableVerboseGC; // default set to FALSE + BOOL bEnableAsyncGC; // default set to TRUE + BOOL bVerbose; // Switch the verbose mode of the VM + BOOL bDebugging; // Enables or disable the debugging VM + UINT32 nDebugPort; // Set the debug port. Only valid with bDebugging = TRUE + BOOL bSecurity; // TRUE, sandbox security enabled. FALSE, no security. Default set to TRUE. + +public: + + TYPEINFO(); + SjJavaSettings(); + + void SetClassPath( const String & rStr ) + { aClassPath = rStr; } + const String & GetClassPath() const { return aClassPath; } + + void SetJavaHomeDir( const String & rStr ) + { aJavaHomeDir = rStr; } + const String & GetJavaHomeDir() const { return aJavaHomeDir; } + + void SetNetAccess( SjNetAccess eAcc ) + { eNetAccess = eAcc; } + SjNetAccess GetNetAccess() const { return eNetAccess; } + + // nSize == 0 -> Systemdefault + void SetMinHeapSize( UINT32 nSize ) + { nMinHeapSize = nSize; } + UINT32 GetMinHeapSize() const { return nMinHeapSize; } + + // nSize == 0 -> Systemdefault + void SetMaxHeapSize( UINT32 nSize ) + { nMaxHeapSize = nSize; } + UINT32 GetMaxHeapSize() const { return nMaxHeapSize; } + + // nSize == 0 -> Systemdefault + void SetNativeStackSize( UINT32 nSize ) + { nNativeStackSize = nSize; } + UINT32 GetNativeStackSize() const { return nNativeStackSize; } + + // nSize == 0 -> Systemdefault + void SetJavaStackSize( UINT32 nSize ) + { nJavaStackSize = nSize; } + UINT32 GetJavaStackSize() const { return nJavaStackSize; } + + // default = 2 -> remotely loaded code + void SetVerifyMode( UINT32 nSize ) + { nVerifyMode = nSize; } + UINT32 GetVerifyMode() const { return nVerifyMode; } + + void EnableClassGC( BOOL bEnable ) + { bEnableClassGC = bEnable; } + UINT32 IsClassGCEnabled() const { return bEnableClassGC; } + + void EnableVerboseGC( BOOL bEnable ) + { bEnableVerboseGC = bEnable; } + UINT32 IsVerboseGCEnabled() const { return bEnableVerboseGC; } + + void EnableAsyncGC( BOOL bEnable ) + { bEnableAsyncGC = bEnable; } + UINT32 IsAsyncGCEnabled() const { return bEnableAsyncGC; } + + void EnableVerboseVM( BOOL bEnable ) + { bVerbose = bEnable; } + UINT32 IsVerboseVMEnabled() const { return bVerbose; } + + void EnableDebugging( BOOL bEnable ) + { bDebugging = bEnable; } + UINT32 IsDebuggingEnabled() const { return bDebugging; } + + void SetDebugPort( UINT32 nPort ) + { nDebugPort = nPort; } + UINT32 GetDebugPort() const { return nDebugPort; } + + + void EnableSecurity( BOOL bEnable ) + { bSecurity = bEnable; } + BOOL IsSecurityEnabled() const { return bSecurity; } + +}; + + +TYPEINIT1( SjJavaSettings, ApplicationProperty ) +SjJavaSettings::SjJavaSettings() +/* [Beschreibung] + + Im Konstruktor werden die Einstellungen des Classpath und JavaHome + auf die Environment Variablen "classpath" und "java_home" initialisiert. +*/ + : eNetAccess( NET_HOST ) + , nNativeStackSize( 0 ) + , nJavaStackSize( 0 ) + , nMinHeapSize( 0 ) + , nMaxHeapSize( 0 ) + , nVerifyMode( 1 ) + , bEnableClassGC( TRUE ) + , bEnableVerboseGC( FALSE ) + , bEnableAsyncGC( TRUE ) + , bDebugging( FALSE ) + , nDebugPort( 0 ) + , bSecurity( TRUE ) +{ +} + +//========================================================================= +//========================================================================= +//========================================================================= +TYPEINIT1( SjINetSettings, ApplicationProperty ) +SjINetSettings::SjINetSettings() +/* [Beschreibung] + + Die Proxy-Servernamen werden auf "" und die Port auf 0 initialisiert. +*/ + : nHttpProxyPort( 0 ) + , nFtpProxyPort( 0 ) + , nFirewallProxyPort( 0 ) +{ +} +#endif // _OLD_FEATURE + + +/* + * Java init function to invoke Java runtime using JNI invocation API. + */ + +void JRE_PropertyChanged( JNIEnv * env, const SvCommandList & rCmdList ) +{ + jclass pClass = env->FindClass("java/util/Properties"); + if( !pClass ) + return; + + jmethodID mCtor = env->GetMethodID( pClass, "<init>", "()V" ); + jobject pProps = env->NewObject( pClass, mCtor, NULL ); + + char * pSignature = "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"; + char * pMethodName = "put"; + jmethodID mPut = env->GetMethodID( pClass, pMethodName, pSignature ); + env->DeleteLocalRef( pClass ); + + if( !mCtor || !pProps || ! mPut ) + return; + + for( ULONG i = 0; i < rCmdList.Count(); i++ ) + { + const SvCommand & rCmd = rCmdList[i]; + jstring pCommand = env->NewString( rCmd.GetCommand().GetBuffer(), rCmd.GetCommand().Len() ); + jstring pArg = env->NewString( rCmd.GetArgument().GetBuffer(), rCmd.GetArgument().Len() ); + + jobject hTmp = env->CallObjectMethod( pProps, mPut, pCommand, pArg ); + env->DeleteLocalRef( hTmp ); + env->DeleteLocalRef( pCommand ); + env->DeleteLocalRef( pArg ); + } + + pClass = env->FindClass("stardiv/controller/SjSettings"); + + if( !pClass ) + return; + + jmethodID mid = env->GetStaticMethodID( pClass , "changeProperties", "(Ljava/util/Properties;)V"); + if( !mid ) + return; + + env->CallStaticVoidMethod( pClass, mid, pProps ); + env->DeleteLocalRef( pProps ); + env->DeleteLocalRef( pClass ); +} + + +void SjApplet2::settingsChanged(void) +{ + Reference<XMultiServiceFactory> serviceManager(getProcessServiceFactory()); + + Reference<XJavaVM> xJavaVM(serviceManager->createInstance(OUString::createFromAscii("com.sun.star.java.JavaVirtualMachine")), UNO_QUERY); + + if(xJavaVM->isVMStarted()) + { + Reference<XJavaThreadRegister_11> xJavaThreadRegister_11(xJavaVM, UNO_QUERY); + + Sequence<sal_Int8> processID(16); + rtl_getGlobalProcessId((sal_uInt8 *)processID.getArray()); + JavaVM * pJVM = (JavaVM *)xJavaVM->getJavaVM(processID).getValue(); + TKTThreadAttach jenv(pJVM, xJavaThreadRegister_11.get()); + + if( jenv.pEnv) + { + DBG_ERROR( "SjApplet2::settingsChanged not implemented" ); +#ifdef _OLD_FEATURE + + SjINetSettings aINetSettings; + GetpApp()->Property(aINetSettings); + SjJavaSettings aJSettings; + GetpApp()->Property(aJSettings); + + SvCommandList aCmdList; + // Security Settings + switch ( aJSettings.GetNetAccess() ) + { + case NET_UNRESTRICTED: + aCmdList.Append( String::CreateFromAscii("appletviewer.security.mode"), + String::CreateFromAscii("unrestricted") ); + break; + + case NET_NONE: + aCmdList.Append( String::CreateFromAscii("appletviewer.security.mode"), + String::CreateFromAscii("none") ); + break; + + case NET_HOST: + aCmdList.Append( String::CreateFromAscii("appletviewer.security.mode"), + String::CreateFromAscii("host") ); + break; + } + if ( aJSettings.IsSecurityEnabled() ) + aCmdList.Append( String::CreateFromAscii("stardiv.security.disableSecurity"), + String::CreateFromAscii("false") ); + else + aCmdList.Append( String::CreateFromAscii("stardiv.security.disableSecurity"), + String::CreateFromAscii("true") ); + + // HTTP settings + aCmdList.Append( String::CreateFromAscii("http.proxyHost"), + aINetSettings.GetHttpProxy()); + aCmdList.Append( String::CreateFromAscii("http.proxyPort"), + aINetSettings.GetHttpProxyPort()); + + // Ftp settings + if( aINetSettings.GetFtpProxy().Len() ) + aCmdList.Append( String::CreateFromAscii("ftpProxySet"), String::CreateFromAscii("true") ); + else + aCmdList.Append( String::CreateFromAscii("ftpProxySet"), String::CreateFromAscii("false") ); + + aCmdList.Append( String::CreateFromAscii("ftpProxyHost"), aINetSettings.GetFtpProxy()); + aCmdList.Append( String::CreateFromAscii("ftpProxyPort"), aINetSettings.GetFtpProxyPort()); + + JRE_PropertyChanged(jenv.pEnv, aCmdList); +#endif //_OLD_FEATURE + } + } +} + diff --git a/sj2/stardiv/app/AppletMessageHandler.java b/sj2/stardiv/app/AppletMessageHandler.java new file mode 100644 index 000000000000..401a8332f5f7 --- /dev/null +++ b/sj2/stardiv/app/AppletMessageHandler.java @@ -0,0 +1,148 @@ +/************************************************************************* + * + * $RCSfile: AppletMessageHandler.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package stardiv.app; + +import java.util.ResourceBundle; +import java.util.MissingResourceException; +import java.text.MessageFormat; + +/** + * An hanlder of localized messages. + * + * @version 1.8, 03/03/97 + * @author Koji Uno + */ +public class AppletMessageHandler { + private static ResourceBundle rb; + private String baseKey = null; + + static { + try { + rb = ResourceBundle.getBundle("stardiv.app.MsgAppletViewer"); + } catch (MissingResourceException e) { + System.out.println(e.getMessage()); + } + }; + + public AppletMessageHandler(String baseKey) { + this.baseKey = baseKey; + } + + public String getMessage(String key) { + return (String)rb.getString(getQualifiedKey(key)); + } + + public String getMessage(String key, Object arg){ + String basemsgfmt = (String)rb.getString(getQualifiedKey(key)); + MessageFormat msgfmt = new MessageFormat(basemsgfmt); + Object msgobj[] = new Object[1]; + if (arg == null) { + arg = "null"; // mimic java.io.PrintStream.print(String) + } + msgobj[0] = arg; + return msgfmt.format(msgobj); + } + + public String getMessage(String key, Object arg1, Object arg2) { + String basemsgfmt = (String)rb.getString(getQualifiedKey(key)); + MessageFormat msgfmt = new MessageFormat(basemsgfmt); + Object msgobj[] = new Object[2]; + if (arg1 == null) { + arg1 = "null"; + } + if (arg2 == null) { + arg2 = "null"; + } + msgobj[0] = arg1; + msgobj[1] = arg2; + return msgfmt.format(msgobj); + } + + public String getMessage(String key, Object arg1, Object arg2, Object arg3) { + String basemsgfmt = (String)rb.getString(getQualifiedKey(key)); + MessageFormat msgfmt = new MessageFormat(basemsgfmt); + Object msgobj[] = new Object[3]; + if (arg1 == null) { + arg1 = "null"; + } + if (arg2 == null) { + arg2 = "null"; + } + if (arg3 == null) { + arg3 = "null"; + } + msgobj[0] = arg1; + msgobj[1] = arg2; + msgobj[2] = arg3; + return msgfmt.format(msgobj); + } + + public String getMessage(String key, Object arg[]) { + String basemsgfmt = (String)rb.getString(getQualifiedKey(key)); + MessageFormat msgfmt = new MessageFormat(basemsgfmt); + return msgfmt.format(arg); + } + + public String getQualifiedKey(String subKey) { + return baseKey + "." + subKey; + } +} diff --git a/sj2/stardiv/app/AppletProps.java b/sj2/stardiv/app/AppletProps.java new file mode 100644 index 000000000000..5b13d4febe76 --- /dev/null +++ b/sj2/stardiv/app/AppletProps.java @@ -0,0 +1,221 @@ +/************************************************************************* + * + * $RCSfile: AppletProps.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package stardiv.app; + +import stardiv.app.AppletMessageHandler; +import stardiv.applet.AppletExecutionContext; + +import java.awt.*; +import java.io.*; +import java.util.Properties; +import sun.net.www.http.HttpClient; +import sun.net.ftp.FtpClient; + +public class AppletProps extends Frame { + TextField proxyHost; + TextField proxyPort; + Choice networkMode; + Choice accessMode; + Choice unsignedMode; + + AppletExecutionContext appletExecutionContext; + + AppletProps(AppletExecutionContext appletExecutionContext) { + this.appletExecutionContext = appletExecutionContext; + + setTitle(amh.getMessage("title")); + Panel p = new Panel(); + p.setLayout(new GridLayout(0, 2)); + + p.add(new Label(amh.getMessage("label.http.server", "Http proxy server:"))); + p.add(proxyHost = new TextField()); + + p.add(new Label(amh.getMessage("label.http.proxy"))); + p.add(proxyPort = new TextField()); + + p.add(new Label(amh.getMessage("label.network"))); + p.add(networkMode = new Choice()); + networkMode.addItem(amh.getMessage("choice.network.item.none")); + networkMode.addItem(amh.getMessage("choice.network.item.applethost")); + networkMode.addItem(amh.getMessage("choice.network.item.unrestricted")); + + String securityMode = System.getProperty("appletviewer.security.mode"); + securityMode = (securityMode == null) ? "none" : securityMode; + securityMode = securityMode.equals("host") ? "applethost" : securityMode; + networkMode.select(amh.getMessage("choice.network.item." + securityMode)); + + p.add(new Label(amh.getMessage("label.class"))); + p.add(accessMode = new Choice()); + accessMode.addItem(amh.getMessage("choice.class.item.restricted")); + accessMode.addItem(amh.getMessage("choice.class.item.unrestricted")); + + accessMode.select(Boolean.getBoolean("package.restrict.access.sun") + ? amh.getMessage("choice.class.item.restricted") + : amh.getMessage("choice.class.item.unrestricted")); + + p.add(new Label(amh.getMessage("label.unsignedapplet"))); + p.add(unsignedMode = new Choice()); + unsignedMode.addItem(amh.getMessage("choice.unsignedapplet.no")); + unsignedMode.addItem(amh.getMessage("choice.unsignedapplet.yes")); + + add("Center", p); + p = new Panel(); + p.add(new Button(amh.getMessage("button.apply"))); + p.add(new Button(amh.getMessage("button.reset"))); + p.add(new Button(amh.getMessage("button.cancel"))); + add("South", p); + setLocation(200, 150); + pack(); + reset(); + } + + void reset() { + // if (Boolean.getBoolean("package.restrict.access.sun")) { + // accessMode.select(amh.getMessage("choice.class.item.restricted")); + // } else { + // accessMode.select(amh.getMessage("choice.class.item.unrestricted")); + // } + + if (System.getProperty("http.proxyHost") != null) { + proxyHost.setText(System.getProperty("http.proxyHost")); + proxyPort.setText(System.getProperty("http.proxyPort")); + HttpClient.proxyPort = Integer.valueOf(System.getProperty("http.proxyPort")).intValue(); + } + else { + proxyHost.setText(""); + proxyPort.setText(""); + } + + // if (Boolean.getBoolean("appletviewer.security.allowUnsigned")) { + // unsignedMode.select(amh.getMessage("choice.unsignedapplet.yes")); + // } else { + // unsignedMode.select(amh.getMessage("choice.unsignedapplet.no")); + // } + } + + void apply() { + // Get properties, set version + Properties props = System.getProperties(); + if (proxyHost.getText().length() > 0) { + props.put("http.proxyHost", proxyHost.getText().trim()); + props.put("http.proxyPort", proxyPort.getText().trim()); + } else { + props.remove("http.proxyHost"); + } + if ("None".equals(networkMode.getSelectedItem())) { + props.put("appletviewer.security.mode", "none"); + } else if ("Unrestricted".equals(networkMode.getSelectedItem())) { + props.put("appletviewer.security.mode", "unrestricted"); + } else { + props.put("appletviewer.security.mode", "host"); + } + + if ("Restricted".equals(accessMode.getSelectedItem())) { + props.put("package.restrict.access.sun", "true"); + props.put("package.restrict.access.netscape", "true"); + props.put("package.restrict.access.stardiv", "true"); + } else { + props.put("package.restrict.access.sun", "false"); + props.put("package.restrict.access.netscape", "false"); + props.put("package.restrict.access.stardiv", "false"); + } + + if ("Yes".equals(unsignedMode.getSelectedItem())) { + props.put("appletviewer.security.allowUnsigned", "true"); + } else { + props.put("appletviewer.security.allowUnsigned", "false"); + } + + // Save properties + try { + reset(); + + FileOutputStream out = new FileOutputStream(AppletViewer.theUserPropertiesFile); + props.save(out, "AppletViewer"); + out.close(); + setVisible( false ); + } catch (IOException e) { + System.out.println(amh.getMessage("apply.exception", e)); + e.printStackTrace(); + reset(); + } + } + + public boolean action(Event evt, Object obj) { + if (amh.getMessage("button.apply").equals(obj)) { + apply(); + return true; + } + if (amh.getMessage("button.reset").equals(obj)) { + reset(); + return true; + } + if (amh.getMessage("button.cancel").equals(obj)) { + setVisible( false ); + return true; + } + return false; + } + + private static AppletMessageHandler amh = new AppletMessageHandler("appletprops"); + +} diff --git a/sj2/stardiv/app/AppletViewer.java b/sj2/stardiv/app/AppletViewer.java new file mode 100644 index 000000000000..0104eebdc5de --- /dev/null +++ b/sj2/stardiv/app/AppletViewer.java @@ -0,0 +1,1025 @@ +/************************************************************************* + * + * $RCSfile: AppletViewer.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +package stardiv.app; + +import java.awt.Toolkit; + +import java.net.InetAddress; + +//import stardiv.applet.AppletMessageHandler; +import stardiv.applet.AppletExecutionContext; +import stardiv.applet.DocumentProxy; + +//import stardiv.js.ip.RootTaskManager; +//import stardiv.js.ip.BaseObj; +//import stardiv.js.ide.Ide; +//import stardiv.js.ne.RunTime; +//import stardiv.js.base.IdentifierPool; +//import stardiv.js.base.Identifier; +//import stardiv.memory.AtomUnion; +//import stardiv.js.ip.Ctor; +import stardiv.controller.SjSettings; + +import java.util.*; +import java.io.*; +import java.awt.*; +import java.awt.event.*; +import java.applet.*; +import java.net.URL; +import java.net.MalformedURLException; + + +/** + * A frame to show the applet tag in. + */ +class TextFrame extends Frame { + /** + * Create the tag frame. + */ + TextFrame(int x, int y, String title, String text) { + setTitle(title); + TextArea txt = new TextArea(20, 60); + txt.setText(text); + txt.setEditable(false); + + add("Center", txt); + + Panel p = new Panel(); + add("South", p); + Button b = new Button(amh.getMessage("button.dismiss", "Dismiss")); + p.add(b); + + class ActionEventListener implements ActionListener { + public void actionPerformed(ActionEvent evt) { + dispose(); + } + } + b.addActionListener(new ActionEventListener()); + + pack(); + setLocation(x, y); + setVisible(true); + + WindowListener windowEventListener = new WindowAdapter() { + + public void windowClosing(WindowEvent evt) { + dispose(); + } + }; + + addWindowListener(windowEventListener); + } + private static AppletMessageHandler amh = new AppletMessageHandler("textframe"); + +} + +/** + * The toplevel applet viewer. + */ +public class AppletViewer extends Frame implements Observer { + com.sun.star.lib.sandbox.ResourceViewer resourceViewer; + + /** + * Some constants... + */ + private static String defaultSaveFile = "Applet.ser"; + + /** + * Look here for the properties file + */ + public static File theUserPropertiesFile; + public static File theAppletViewerPropsFile; + + //private Ide aIde; + //private RootTaskManager aRTM; + //private BaseObj aRootObj; + + private AppletExecutionContext appletExecutionContext = null; + Hashtable atts = null; + + static DocumentProxy documentViewer = null; + + /** + * The status line. + */ + Label label; + + /** + * output status messages to this stream + */ + + PrintStream statusMsgStream; + + static Vector contexts = new Vector(); + + private final class UserActionListener implements ActionListener { + public void actionPerformed(ActionEvent evt) { + processUserAction(evt); + } + } + + static { + String sep = File.separator; + + File userHome = new File(System.getProperty("user.home")); + + File AVHome = new File(userHome, ".hotjava"); + // ensure the props folder can be made + AVHome.mkdirs(); + + theUserPropertiesFile = new File(AVHome, "properties"); + File JH = new File(System.getProperty("java.home")); + theAppletViewerPropsFile = new File(JH, "lib" + sep + "appletviewer.properties"); + }; + + /** + * Create the applet viewer + */ + public AppletViewer(int x, int y, URL doc, Hashtable atts, PrintStream statusMsgStream) { +// resourceViewer = new stardiv.util.ResourceViewer(); +// resourceViewer.show(); + System.err.println("#*#*#*:" + sun.awt.ScreenUpdater.updater); + this.statusMsgStream = statusMsgStream; + this.atts = atts; + + setTitle(amh.getMessage("tool.title", atts.get("code"))); + + MenuBar mb = new MenuBar(); + + Menu m = new Menu(amh.getMessage("menu.applet")); + + addMenuItem(m, "menuitem.restart"); + addMenuItem(m, "menuitem.reload"); + addMenuItem(m, "menuitem.stop"); + addMenuItem(m, "menuitem.save"); + addMenuItem(m, "menuitem.start"); + addMenuItem(m, "menuitem.clone"); + m.add(new MenuItem("-")); + addMenuItem(m, "menuitem.tag"); + addMenuItem(m, "menuitem.info"); + addMenuItem(m, "menuitem.edit").setEnabled( false ); + addMenuItem(m, "menuitem.encoding"); + m.add(new MenuItem("-")); + addMenuItem(m, "menuitem.print"); + m.add(new MenuItem("-")); + addMenuItem(m, "menuitem.props"); + m.add(new MenuItem("-")); + addMenuItem(m, "menuitem.close"); + // if (factory.isStandalone()) { + addMenuItem(m, "menuitem.quit"); + // } + + mb.add(m); + + setMenuBar(mb); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent evt) { + appletExecutionContext.shutdown(); + } + + public void windowIconified(WindowEvent evt) { + appletExecutionContext.sendLoad(); + } + + public void windowDeiconified(WindowEvent evt) { + appletExecutionContext.sendStart(); + } + }); + + add("South", label = new Label(amh.getMessage("label.hello"))); + + appletExecutionContext = new AppletExecutionContext(doc, atts, this, 0); + appletExecutionContext.init(); + + appletExecutionContext.addObserver(this); + contexts.addElement(appletExecutionContext); + + pack(); + setVisible(true); + +// appletExecutionContext.send(); + appletExecutionContext.startUp(); + +/* + if( atts.get( "mayscript" ) != null ) { + aIde = new Ide(); + aRTM = aIde.getActRootTaskManager(); + aRootObj = new BaseObj( aRTM ); + //Ctor aCtor = new AppletCtor( aRTM, "Window" ); + //aRootObj.initProperties( aCtor, aCtor.getStaticPropCount(), aCtor.getBasePropCount() ); + //aRootObj.setCtor( aCtor ); + aRTM.setRootObj( aRootObj ); + RunTime aRT = new RunTime( aRootObj, aRTM ); + aIde.setRootObj( aRootObj ); + + AtomUnion aAU = new AtomUnion(); + BaseObj aDocument = new BaseObj( aRTM ); + aAU.setObject( aDocument ); + Identifier aId = IdentifierPool.aGlobalPool.addIdentifier( "RootObject" ); + aRootObj.newProperty( aId, aAU ); + IdentifierPool.aGlobalPool.releaseIdentifier( aId ); + + String pName = (String)atts.get( "name" ); + if( pName != null ) { + BaseObj aApplet = new BaseObj( aRTM ); + aAU.setObject( aApplet ); + aId = IdentifierPool.aGlobalPool.addIdentifier( pName ); + aDocument.newProperty( aId, aAU ); + IdentifierPool.aGlobalPool.releaseIdentifier( aId ); + } + } + */ + } + + public MenuItem addMenuItem(Menu m, String s) { + MenuItem mItem = new MenuItem(amh.getMessage(s)); + mItem.addActionListener(new UserActionListener()); + return m.add(mItem); + } + + /** + * Ignore. + */ + public void showDocument(URL url) { + } + + /** + * Ignore. + */ + public void showDocument(URL url, String target) { + } + + /** + * Show status. + */ + public void showStatus(String status) { + label.setText(status); + } + + public void update(Observable observable, Object status) { + showStatus((String)status); + } + + public Object getJavaScriptJSObjectWindow() { + //if( aRootObj != null ) + // return aRootObj.getJSObject(); + return null; + } + + + /** + * System parameters. + */ + static Hashtable systemParam = new Hashtable(); + + static { + systemParam.put("codebase", "codebase"); + systemParam.put("code", "code"); + systemParam.put("alt", "alt"); + systemParam.put("width", "width"); + systemParam.put("height", "height"); + systemParam.put("align", "align"); + systemParam.put("vspace", "vspace"); + systemParam.put("hspace", "hspace"); + } + + /** + * Print the HTML tag. + */ + public static void printTag(PrintStream out, Hashtable atts) { + out.print("<applet"); + + String v = (String)atts.get("codebase"); + if (v != null) { + out.print(" codebase=\"" + v + "\""); + } + + v = (String)atts.get("code"); + if (v == null) { + v = "applet.class"; + } + out.print(" code=\"" + v + "\""); + v = (String)atts.get("width"); + if (v == null) { + v = "150"; + } + out.print(" width=" + v); + + v = (String)atts.get("height"); + if (v == null) { + v = "100"; + } + out.print(" height=" + v); + + v = (String)atts.get("name"); + if (v != null) { + out.print(" name=\"" + v + "\""); + } + out.println(">"); + + // A very slow sorting algorithm + int len = atts.size(); + String params[] = new String[len]; + len = 0; + for (Enumeration e = atts.keys() ; e.hasMoreElements() ;) { + String param = (String)e.nextElement(); + int i = 0; + for (; i < len ; i++) { + if (params[i].compareTo(param) >= 0) { + break; + } + } + System.arraycopy(params, i, params, i + 1, len - i); + params[i] = param; + len++; + } + + for (int i = 0 ; i < len ; i++) { + String param = params[i]; + if (systemParam.get(param) == null) { + out.println("<param name=" + param + + " value=\"" + atts.get(param) + "\">"); + } + } + out.println("</applet>"); + } + + /** + * Make sure the atrributes are uptodate. + */ + public void updateAtts() { + Dimension d = getSize(); + Insets in = getInsets(); + atts.put("width", new Integer(d.width - (in.left + in.right)).toString()); + atts.put("height", new Integer(d.height - (in.top + in.bottom)).toString()); + } + + /** + * Save the applet to a well known file (for now) as a serialized object + */ + void appletSave() { + // REMIND -- should check that the applet has really stopped + FileDialog fd = new FileDialog(this, "Serialize Applet into File", FileDialog.SAVE); + // needed for a bug under Solaris... + fd.setDirectory(System.getProperty("user.dir")); + fd.setFile(defaultSaveFile); + fd.show(); + String fname = fd.getFile(); + if (fname == null) { + return; // cancelled + } + String dname = fd.getDirectory(); + File file = new File(dname, fname); + + try { + OutputStream s = new FileOutputStream(file); + ObjectOutputStream os = new ObjectOutputStream(s); + showStatus(amh.getMessage("appletsave.err1", + appletExecutionContext.getApplet().toString(), file.toString())); + os.writeObject(appletExecutionContext.getApplet()); + } catch (IOException ex) { + System.err.println(amh.getMessage("appletsave.err2", ex)); + } + } + + /** + * Clone the viewer and the applet. + */ + void appletClone() { + Point p = getLocation(); + updateAtts(); + // factory.createAppletViewer(p.x + 30, p.y + 10, + // pHelper.panel.documentURL, (Hashtable)pHelper.panel.atts.clone()); + } + + /** + * Show the applet tag. + */ + void appletTag() { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + updateAtts(); + printTag(new PrintStream(out), atts); + showStatus(amh.getMessage("applettag")); + + Point p = getLocation(); + new TextFrame(p.x + 50, p.y + 20, amh.getMessage("applettag.textframe"), out.toString()); + } + + /** + * Show the applet info. + */ + void appletInfo() { + String str = appletExecutionContext.getApplet().getAppletInfo(); + if (str == null) { + str = amh.getMessage("appletinfo.applet"); + } + str += "\n\n"; + + String atts[][] = appletExecutionContext.getApplet().getParameterInfo(); + if (atts != null) { + for (int i = 0 ; i < atts.length ; i++) { + str += atts[i][0] + " -- " + atts[i][1] + " -- " + atts[i][2] + "\n"; + } + } else { + str += amh.getMessage("appletinfo.param"); + } + + Point p = getLocation(); + new TextFrame(p.x + 50, p.y + 20, amh.getMessage("appletinfo.textframe"), str); + + } + + /** + * Show character encoding type + */ + void appletCharacterEncoding() { + showStatus(amh.getMessage("appletencoding", encoding)); + } + + /** + * Edit the applet. + */ + void appletEdit() { + } + + /** + * Print the applet. + */ + void appletPrint() { + PrintJob pj = Toolkit.getDefaultToolkit(). + getPrintJob(this, amh.getMessage("appletprint.printjob"), (Properties)null); + + + if (pj != null) { + Dimension pageDim = pj.getPageDimension(); + int pageRes = pj.getPageResolution(); + boolean lastFirst = pj.lastPageFirst(); + + Graphics g = pj.getGraphics(); + if (g != null) { + appletExecutionContext.getApplet().printComponents(g); + g.dispose(); + } else { + statusMsgStream.println(amh.getMessage("appletprint.fail")); + } + statusMsgStream.println(amh.getMessage("appletprint.finish")); + pj.end(); + + } else { + statusMsgStream.println(amh.getMessage("appletprint.cancel")); + } + } + + /** + * Properties. + */ + AppletProps props; + public synchronized void networkProperties() { + if (props == null) { + props = new AppletProps(appletExecutionContext); + } + props.addNotify(); + props.setVisible(true); + } + + /** + * Close this viewer. + * Stop, Destroy, Dispose and Quit an AppletView, then + * reclaim resources and exit the program if this is + * the last applet. + */ + public void appletClose() { + appletExecutionContext.shutdown(); + contexts.removeElement(this); + + if (contexts.size() == 0) { + appletSystemExit(); + } + } + + +// public static void writeClasses() { +// try { +// java.io.FileOutputStream file = new FileOutputStream("classes.txt"); +// java.io.PrintStream printStream = new java.io.PrintStream(file); + +// printStream.println("- .* .*"); +// Enumeration elements = stardiv.util.HardClassContext.classList.elements(); +// while(elements.hasMoreElements()) { +// String string = (String)elements.nextElement(); + +// String packageName = ""; +// String className = string; + +// int lastIndex = string.lastIndexOf('.'); +// if(lastIndex > -1) { +// packageName = string.substring(0, lastIndex); +// className = string.substring(lastIndex + 1); +// } + +// printStream.print("+ "); +// int index; +// while((index = packageName.indexOf('.')) > -1) { +// printStream.print(packageName.substring(0, index) + "\\\\"); +// packageName = packageName.substring(index + 1); +// } +// printStream.print(packageName + " "); + +// while((index = className.indexOf('$')) > -1) { +// printStream.print(className.substring(0, index) + "\\$"); +// className = className.substring(index + 1); +// } +// printStream.println(className + "\\.class"); +// } +// file.close(); +// } +// catch(java.io.IOException eio) { +// System.err.println("IOException:" + eio); +// } +// } + + /** + * Exit the program. + * Exit from the program (if not stand alone) - do no clean-up + */ + private void appletSystemExit() { + // if (factory.isStandalone()) + System.exit(0); + } + + /** + * Quit all viewers. + * Shutdown all viewers properly then + * exit from the program (if not stand alone) + */ + protected void appletQuit() { + appletExecutionContext.shutdown(); + appletSystemExit(); + } + + /** + * Handle events. + */ + public void processUserAction(ActionEvent evt) { + + String label = ((MenuItem)evt.getSource()).getLabel(); + + if (amh.getMessage("menuitem.restart").equals(label)) { + appletExecutionContext.restart(); + return; + } + + if (amh.getMessage("menuitem.reload").equals(label)) { + appletExecutionContext.reload(); + return; + } + + if (amh.getMessage("menuitem.clone").equals(label)) { + appletClone(); + return; + } + + if (amh.getMessage("menuitem.stop").equals(label)) { + appletExecutionContext.sendStop(); + return; + } + + if (amh.getMessage("menuitem.save").equals(label)) { + appletSave(); + return; + } + + if (amh.getMessage("menuitem.start").equals(label)) { + appletExecutionContext.sendStart(); + return; + } + + if (amh.getMessage("menuitem.tag").equals(label)) { + appletTag(); + return; + } + + if (amh.getMessage("menuitem.info").equals(label)) { + appletInfo(); + return; + } + + if (amh.getMessage("menuitem.encoding").equals(label)) { + appletCharacterEncoding(); + return; + } + + if (amh.getMessage("menuitem.edit").equals(label)) { + appletEdit(); + return; + } + + if (amh.getMessage("menuitem.print").equals(label)) { + appletPrint(); + return; + } + + if (amh.getMessage("menuitem.props").equals(label)) { + networkProperties(); + return; + } + + if (amh.getMessage("menuitem.close").equals(label)) { + appletClose(); + return; + } + + if (/*factory.isStandalone() && */amh.getMessage("menuitem.quit").equals(label)) { + appletQuit(); + return; + } + //statusMsgStream.println("evt = " + evt); + } + + /** + * Prepare the enviroment for executing applets. + */ + public static void init() { + Properties props = new Properties(); + props.put( "http.proxyHost", "wwwproxy" ); + props.put( "http.proxyPort", "3128" ); + props.put( "ftpProxySet", "true" ); + props.put( "ftpProxyHost", "wwwproxy" ); + props.put( "ftpProxyPort", "3128" ); + props.put( "ftpProxyPort", "3128" ); + props.put( "stardiv.debug.trace", "window" ); + props.put( "stardiv.debug.warning", "window" ); + props.put( "stardiv.debug.error", "window" ); + props.put( "stardiv.security.defaultSecurityManager", "true" ); + + // Try loading the appletviewer properties file to get messages, etc. +// try { +// FileInputStream in = new FileInputStream(theAppletViewerPropsFile); +// props.load(new BufferedInputStream(in)); +// in.close(); +// } catch (Exception e) { +// System.out.println(amh.getMessage("init.err")); +// } + + // Try loading the saved user properties file to override some + // of the above defaults. + try { + FileInputStream in = new FileInputStream(theUserPropertiesFile); + props.load(new BufferedInputStream(in)); + in.close(); + } catch (Exception e) { + /* is it really necessary to say this? + This is always the case the first time we run.. + System.out.println("[no properties loaded, using defaults]"); */ + } + + // Install a property list. + + SjSettings.changeProperties(props); + } + + /** + * The current character. + */ + static int c; + + /** + * Scan spaces. + */ + public static void skipSpace(Reader in) throws IOException { + while ((c >= 0) && ((c == ' ') || (c == '\t') || (c == '\n') || (c == '\r'))) { + c = in.read(); + } + } + + /** + * Scan identifier + */ + public static String scanIdentifier(Reader in) throws IOException { + StringBuffer buf = new StringBuffer(); + while (true) { + if (((c >= 'a') && (c <= 'z')) || + ((c >= 'A') && (c <= 'Z')) || + ((c >= '0') && (c <= '9')) || (c == '_')) { + buf.append((char)c); + c = in.read(); + } else { + return buf.toString(); + } + } + } + + /** + * Scan tag + */ + public static Hashtable scanTag(Reader in) throws IOException { + Hashtable atts = new Hashtable(); + skipSpace(in); + while (c >= 0 && c != '>') { + String att = scanIdentifier(in); + String val = ""; + skipSpace(in); + if (c == '=') { + int quote = -1; + c = in.read(); + skipSpace(in); + if ((c == '\'') || (c == '\"')) { + quote = c; + c = in.read(); + } + StringBuffer buf = new StringBuffer(); + while ((c > 0) && + (((quote < 0) && (c != ' ') && (c != '\t') && + (c != '\n') && (c != '\r') && (c != '>')) + || ((quote >= 0) && (c != quote)))) { + buf.append((char)c); + c = in.read(); + } + if (c == quote) { + c = in.read(); + } + skipSpace(in); + val = buf.toString(); + } + //statusMsgStream.println("PUT " + att + " = '" + val + "'"); + atts.put(att.toLowerCase(), val); + skipSpace(in); + } + return atts; + } + + static int x = 100; + static int y = 50; + + static String encoding = null; + + static private Reader makeReader(InputStream is) { + if (encoding != null) { + try { + return new BufferedReader(new InputStreamReader(is, encoding)); + } catch (IOException x) { } + } + InputStreamReader r = new InputStreamReader(is); + encoding = r.getEncoding(); + return new BufferedReader(r); + } + + /** + * Scan an html file for <applet> tags + */ + public static void parse(URL url) throws IOException { + parse(url, System.out); + } + + public static void parse(URL url, PrintStream statusMsgStream) throws IOException { + + // warning messages + String requiresNameWarning = amh.getMessage("parse.warning.requiresname"); + String paramOutsideWarning = amh.getMessage("parse.warning.paramoutside"); + String requiresCodeWarning = amh.getMessage("parse.warning.requirescode"); + String requiresHeightWarning = amh.getMessage("parse.warning.requiresheight"); + String requiresWidthWarning = amh.getMessage("parse.warning.requireswidth"); + String appNotLongerSupportedWarning = amh.getMessage("parse.warning.appnotLongersupported"); + + java.net.URLConnection conn = url.openConnection(); + Reader in = makeReader(conn.getInputStream()); + /* The original URL may have been redirected - this + * sets it to whatever URL/codebase we ended up getting + */ + url = conn.getURL(); + + Hashtable atts = null; + while(true) { + c = in.read(); + if (c == -1) + break; + + if (c == '<') { + c = in.read(); + if (c == '/') { + c = in.read(); + String nm = scanIdentifier(in); + if (nm.equalsIgnoreCase("applet")) { + if (atts != null) { + new AppletViewer(x, y, url, atts, System.out); + x += 50; + y += 20; + // make sure we don't go too far! + Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); + if (x > d.width - 30) + x = 100; + if (y > d.height - 30) + y = 50; + } + atts = null; + } + } + else { + String nm = scanIdentifier(in); + if (nm.equalsIgnoreCase("param")) { + Hashtable t = scanTag(in); + String att = (String)t.get("name"); + if (att == null) { + statusMsgStream.println(requiresNameWarning); + } else { + String val = (String)t.get("value"); + if (val == null) { + statusMsgStream.println(requiresNameWarning); + } else if (atts != null) { + atts.put(att.toLowerCase(), val); + } else { + statusMsgStream.println(paramOutsideWarning); + } + } + } + else if (nm.equalsIgnoreCase("applet")) { + atts = scanTag(in); + if (atts.get("code") == null && atts.get("object") == null) { + statusMsgStream.println(requiresCodeWarning); + atts = null; + } else if (atts.get("width") == null) { + statusMsgStream.println(requiresWidthWarning); + atts = null; + } else if (atts.get("height") == null) { + statusMsgStream.println(requiresHeightWarning); + atts = null; + } + } + else if (nm.equalsIgnoreCase("app")) { + statusMsgStream.println(appNotLongerSupportedWarning); + Hashtable atts2 = scanTag(in); + nm = (String)atts2.get("class"); + if (nm != null) { + atts2.remove("class"); + atts2.put("code", nm + ".class"); + } + nm = (String)atts2.get("src"); + if (nm != null) { + atts2.remove("src"); + atts2.put("codebase", nm); + } + if (atts2.get("width") == null) { + atts2.put("width", "100"); + } + if (atts2.get("height") == null) { + atts2.put("height", "100"); + } + printTag(statusMsgStream, atts2); + statusMsgStream.println(); + } + } + } + } + in.close(); + } + + /** + * Print usage + */ + static void usage() { + System.out.println(amh.getMessage("usage")); + } + + static boolean didInitialize = false; + + /** + * mainInit can be called by direct clients + */ + public static void mainInit() { + if (! didInitialize) { + didInitialize = true; + + init(); + + } + } + + /** + * Main + */ + public static void main(String argv[]) { + mainInit(); + + // Parse arguments + if (argv.length == 0) { + System.out.println(amh.getMessage("main.err.inputfile")); + usage(); + return; + } + + // Parse the documents + for (int i = 0 ; i < argv.length ; i++) { + try { + URL url = null; + + if (argv[i].equals("-encoding")) { + if(i + 1 < argv.length) { + i++; + encoding = argv[i]; + continue; + } else { + usage(); + System.exit(1); + } + } + else + if (argv[i].indexOf(':') <= 1) { + String userDir = System.getProperty("user.dir"); + String prot; + // prepend native separator to path iff not present + if (userDir.charAt(0) == '/' || + userDir.charAt(0) == java.io.File.separatorChar) { + prot = "file:"; + } else { + prot = "file:/"; + } + url = new URL(prot + userDir.replace(File.separatorChar, '/') + + "/"); + url = new URL(url, argv[i]); + } else { + url = new URL(argv[i]); + } + + parse(url); + documentViewer = DocumentProxy.getDocumentProxy(url, Toolkit.getDefaultToolkit()); + } catch (MalformedURLException e) { + System.out.println(amh.getMessage("main.err.badurl", argv[i], e.getMessage())); + System.exit(1); + } catch (IOException e) { + System.out.println(amh.getMessage("main.err.io", e.getMessage())); + if (argv[i].indexOf(':') < 0) { + System.out.println(amh.getMessage("main.err.readablefile", argv[i])); + } else { + System.out.println(amh.getMessage("main.err.correcturl", argv[i])); + } + System.exit(1); + } + } + /* + if (documentViewer.countApplets() == 0) { + System.out.println(amh.getMessage("main.warning")); + usage(); + System.exit(1); + }*/ + } + private static AppletMessageHandler amh = new AppletMessageHandler("appletviewer"); +} diff --git a/sj2/stardiv/app/AppletViewerFactory.java b/sj2/stardiv/app/AppletViewerFactory.java new file mode 100644 index 000000000000..c2019046be71 --- /dev/null +++ b/sj2/stardiv/app/AppletViewerFactory.java @@ -0,0 +1,77 @@ +/************************************************************************* + * + * $RCSfile: AppletViewerFactory.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +/* + * AppletViewerFactory.java + */ + +package stardiv.app; + +import java.util.Hashtable; +import java.net.URL; +import java.awt.MenuBar; + +public +interface AppletViewerFactory { + public AppletViewer createAppletViewer(int x, int y, URL doc, Hashtable atts); + public MenuBar getBaseMenuBar(); + public boolean isStandalone(); +} diff --git a/sj2/stardiv/app/MsgAppletViewer.java b/sj2/stardiv/app/MsgAppletViewer.java new file mode 100644 index 000000000000..e37d74f724ab --- /dev/null +++ b/sj2/stardiv/app/MsgAppletViewer.java @@ -0,0 +1,220 @@ +/************************************************************************* + * + * $RCSfile: MsgAppletViewer.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +package stardiv.app; + +import java.util.ListResourceBundle; + +public class MsgAppletViewer extends ListResourceBundle { + + public Object[][] getContents() { + return contents; + } + + static final Object[][] contents = { + {"textframe.button.dismiss", "Dismiss"}, + {"appletviewer.tool.title", "Applet Viewer: {0}"}, + {"appletviewer.menu.applet", "Applet"}, + {"appletviewer.menuitem.restart", "Restart"}, + {"appletviewer.menuitem.reload", "Reload"}, + {"appletviewer.menuitem.stop", "Stop"}, + {"appletviewer.menuitem.save", "Save..."}, + {"appletviewer.menuitem.start", "Start"}, + {"appletviewer.menuitem.clone", "Clone..."}, + {"appletviewer.menuitem.tag", "Tag..."}, + {"appletviewer.menuitem.info", "Info..."}, + {"appletviewer.menuitem.edit", "Edit"}, + {"appletviewer.menuitem.encoding", "Character Encoding"}, + {"appletviewer.menuitem.print", "Print..."}, + {"appletviewer.menuitem.props", "Properties..."}, + {"appletviewer.menuitem.close", "Close"}, + {"appletviewer.menuitem.quit", "Quit"}, + {"appletviewer.label.hello", "Hello..."}, + {"appletviewer.status.start", "starting applet..."}, + {"appletviewer.appletsave.err1", "serializing an {0} to {1}"}, + {"appletviewer.appletsave.err2", "in appletSave: {0}"}, + {"appletviewer.applettag", "Tag shown"}, + {"appletviewer.applettag.textframe", "Applet HTML Tag"}, + {"appletviewer.appletinfo.applet", "-- no applet info --"}, + {"appletviewer.appletinfo.param", "-- no parameter info --"}, + {"appletviewer.appletinfo.textframe", "Applet Info"}, + {"appletviewer.appletprint.printjob", "Print Applet"}, + {"appletviewer.appletprint.fail", "Printing failed."}, + {"appletviewer.appletprint.finish", "Finished printing."}, + {"appletviewer.appletprint.cancel", "Printing cancelled."}, + {"appletviewer.appletencoding", "Character Encoding: {0}"}, + {"appletviewer.init.err", "[no appletviewer.properties file found!]"}, + {"appletviewer.parse.warning.requiresname", "Warning: <param name=... value=...> tag requires name attribute."}, + {"appletviewer.parse.warning.paramoutside", "Warning: <param> tag outside <applet> ... </applet>."}, + {"appletviewer.parse.warning.requirescode", "Warning: <applet> tag requires code attribute."}, + {"appletviewer.parse.warning.requiresheight", "Warning: <applet> tag requires height attribute."}, + {"appletviewer.parse.warning.requireswidth", "Warning: <applet> tag requires width attribute."}, + {"appletviewer.parse.warning.appnotLongersupported", "Warning: <app> tag no longer supported, use <applet> instead:"}, + {"appletviewer.usage", "usage: appletviewer [-debug] [-J<javaflag>] [-encoding <character encoding type> ] url|file ..."}, + {"appletviewer.main.err.inputfile", "No input files specified."}, + {"appletviewer.main.err.badurl", "Bad URL: {0} ( {1} )"}, + {"appletviewer.main.err.io", "I/O exception while reading: {0}"}, + {"appletviewer.main.err.readablefile", "Make sure that {0} is a file and is readable."}, + {"appletviewer.main.err.correcturl", "Is {0} the correct URL?"}, + {"appletviewer.main.warning", "Warning: No Applets were started. Make sure the input contains an <applet> tag."}, + {"appletioexception.loadclass.throw.interrupted", "class loading interrupted: {0}"}, + {"appletioexception.loadclass.throw.notloaded", "class not loaded: {0}"}, + {"appletclassloader.loadcode.verbose", "Opening stream to: {0} to get {1}"}, + {"appletclassloader.filenotfound", "File not found when looking for: {0}"}, + {"appletclassloader.fileformat", "File format exception when loading: {0}"}, + {"appletclassloader.fileioexception", "I/O exception when loading: {0}"}, + {"appletclassloader.fileexception", "{0} exception when loading: {1}"}, + {"appletclassloader.filedeath", "{0} killed when loading: {1}"}, + {"appletclassloader.fileerror", "{0} error when loading: {1}"}, + {"appletclassloader.findclass.verbose.findclass", "{0} find class {1}"}, + {"appletclassloader.findclass.verbose.openstream", "Opening stream to: {0} to get {1}"}, + {"appletclassloader.getresource.verbose.forname", "AppletClassLoader.getResource for name: {0}"}, + {"appletclassloader.getresource.verbose.found", "Found resource: {0} as a system resource"}, + {"appletclassloader.getresourceasstream.verbose", "Found resource: {0} as a system resource"}, + {"appletcopyright.title", "Copyright Notice"}, + {"appletcopyright.button.accept", "Accept"}, + {"appletcopyright.button.reject", "Reject"}, + {"appletcopyright.defaultcontent", "Copyright (c) 1995, 1996, 1997 Sun Microsystems, Inc."}, + {"appletcopyright.copyrightfile", "COPYRIGHT"}, + {"appletcopyright.copyrightencoding", "8859_1"}, + {"appletpanel.runloader.err", "Either object or code parameter!"}, + {"appletpanel.runloader.exception", "exception while deserializing {0}"}, + {"appletpanel.destroyed", "Applet destroyed."}, + {"appletpanel.loaded", "Applet loaded."}, + {"appletpanel.started", "Applet started."}, + {"appletpanel.inited", "Applet initialized."}, + {"appletpanel.stopped", "Applet stopped."}, + {"appletpanel.disposed", "Applet disposed."}, + {"appletpanel.nocode", "APPLET tag missing CODE parameter."}, + {"appletpanel.notfound", "load: class {0} not found."}, + {"appletpanel.nocreate", "load: {0} can''t be instantiated."}, + {"appletpanel.noconstruct", "load: {0} is not public or has no public constructor."}, + {"appletpanel.death", "killed"}, + {"appletpanel.exception", "exception: {0}."}, + {"appletpanel.exception2", "exception: {0}: {1}."}, + {"appletpanel.error", "error: {0}."}, + {"appletpanel.error2", "error: {0}: {1}."}, + {"appletpanel.notloaded", "Init: applet not loaded."}, + {"appletpanel.notinited", "Start: applet not initialized."}, + {"appletpanel.notstarted", "Stop: applet not started."}, + {"appletpanel.notstopped", "Destroy: applet not stopped."}, + {"appletpanel.notdestroyed", "Dispose: applet not destroyed."}, + {"appletpanel.notdisposed", "Load: applet not disposed."}, + {"appletpanel.bail", "Interrupted: bailing out."}, + {"appletpanel.filenotfound", "File not found when looking for: {0}"}, + {"appletpanel.fileformat", "File format exception when loading: {0}"}, + {"appletpanel.fileioexception", "I/O exception when loading: {0}"}, + {"appletpanel.fileexception", "{0} exception when loading: {1}"}, + {"appletpanel.filedeath", "{0} killed when loading: {1}"}, + {"appletpanel.fileerror", "{0} error when loading: {1}"}, + {"appletillegalargumentexception.objectinputstream", "AppletObjectInputStream requires non-null loader"}, + {"appletprops.title", "AppletViewer Properties"}, + {"appletprops.label.http.server", "Http proxy server:"}, + {"appletprops.label.http.proxy", "Http proxy port:"}, + {"appletprops.label.network", "Network access:"}, + {"appletprops.choice.network.item.none", "None"}, + {"appletprops.choice.network.item.applethost", "Applet Host"}, + {"appletprops.choice.network.item.unrestricted", "Unrestricted"}, + {"appletprops.label.class", "Class access:"}, + {"appletprops.choice.class.item.restricted", "Restricted"}, + {"appletprops.choice.class.item.unrestricted", "Unrestricted"}, + {"appletprops.label.unsignedapplet", "Allow unsigned applets:"}, + {"appletprops.choice.unsignedapplet.no", "No"}, + {"appletprops.choice.unsignedapplet.yes", "Yes"}, + {"appletprops.button.apply", "Apply"}, + {"appletprops.button.cancel", "Cancel"}, + {"appletprops.button.reset", "Reset"}, + {"appletprops.apply.exception", "Failed to save properties: {0}"}, + {"appletsecurityexception.checkcreateclassloader", "Security Exception: classloader"}, + {"appletsecurityexception.checkaccess.thread", "Security Exception: thread"}, + {"appletsecurityexception.checkaccess.threadgroup", "Security Exception: threadgroup: {0}"}, + {"appletsecurityexception.checkexit", "Security Exception: exit: {0}"}, + {"appletsecurityexception.checkexec", "Security Exception: exec: {0}"}, + {"appletsecurityexception.checklink", "Security Exception: link: {0}"}, + {"appletsecurityexception.checkpropsaccess", "Security Exception: properties"}, + {"appletsecurityexception.checkpropsaccess.key", "Security Exception: properties access {0}"}, + {"appletsecurityexception.checkread.exception1", "Security Exception: {0}, {1}"}, + {"appletsecurityexception.checkread.exception2", "Security Exception: file.read: {0}"}, + {"appletsecurityexception.checkread", "Security Exception: file.read: {0} == {1}"}, + {"appletsecurityexception.checkwrite.exception", "Security Exception: {0}, {1}"}, + {"appletsecurityexception.checkwrite", "Security Exception: file.write: {0} == {1}"}, + {"appletsecurityexception.checkread.fd", "Security Exception: fd.read"}, + {"appletsecurityexception.checkwrite.fd", "Security Exception: fd.write"}, + {"appletsecurityexception.checklisten", "Security Exception: socket.listen: {0}"}, + {"appletsecurityexception.checkaccept", "Security Exception: socket.accept: {0}:{1}"}, + {"appletsecurityexception.checkconnect.networknone", "Security Exception: socket.connect: {0}->{1}"}, + {"appletsecurityexception.checkconnect.networkhost1", "Security Exception: Couldn''t connect to {0} with origin from {1}."}, + {"appletsecurityexception.checkconnect.networkhost2", "Security Exception: Couldn''t resolve IP for host {0} or for {1}. "}, + {"appletsecurityexception.checkconnect.networkhost3", "Security Exception: Could not resolve IP for host {0}. See the trustProxy property."}, + {"appletsecurityexception.checkconnect", "Security Exception: connect: {0}->{1}"}, + {"appletsecurityexception.checkpackageaccess", "Security Exception: cannot access package: {0}"}, + {"appletsecurityexception.checkpackagedefinition", "Security Exception: cannot define package: {0}"}, + {"appletsecurityexception.cannotsetfactory", "Security Exception: cannot set factory"}, + {"appletsecurityexception.checkmemberaccess", "Security Exception: check member access"}, + {"appletsecurityexception.checkgetprintjob", "Security Exception: getPrintJob"}, + {"appletsecurityexception.checksystemclipboardaccess", "Security Exception: getSystemClipboard"}, + {"appletsecurityexception.checkawteventqueueaccess", "Security Exception: getEventQueue"}, + {"appletsecurityexception.checksecurityaccess", "Security Exception: security operation: {0}"}, + {"appletsecurityexception.getsecuritycontext.unknown", "unknown class loader type. unable to check for getContext"}, + {"appletsecurityexception.checkread.unknown", "unknown class loader type. unable to check for checking read {0}"}, + {"appletsecurityexception.checkconnect.unknown", "unknown class loader type. unable to check for checking connect"}, + {"appletsecurityexception.getresource.noclassaccess", "Cannot use getResource to access .class file: {0} in JDK1.1"}, + }; +} diff --git a/sj2/stardiv/app/makefile.mk b/sj2/stardiv/app/makefile.mk new file mode 100644 index 000000000000..aa0f441c0e73 --- /dev/null +++ b/sj2/stardiv/app/makefile.mk @@ -0,0 +1,95 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=sj2 +TARGET=app + +PACKAGE=stardiv$/app +JARFILES=sandbox.jar + +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +JAVAFILES= \ + AppletViewer.java \ + AppletViewerFactory.java \ + AppletProps.java \ + AppletMessageHandler.java \ + MsgAppletViewer.java + +JAVACLASSFILES= \ + $(CLASSDIR)$/$(PACKAGE)$/AppletViewer.class \ + $(CLASSDIR)$/$(PACKAGE)$/AppletViewerFactory.class \ + $(CLASSDIR)$/$(PACKAGE)$/AppletProps.class \ + $(CLASSDIR)$/$(PACKAGE)$/AppletMessageHandler.class \ + $(CLASSDIR)$/$(PACKAGE)$/MsgAppletViewer.class + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +.INCLUDE : $(PRJ)$/util$/target.pmk + diff --git a/sj2/stardiv/applet/AppletExecutionContext.java b/sj2/stardiv/applet/AppletExecutionContext.java new file mode 100644 index 000000000000..faf36b0a9262 --- /dev/null +++ b/sj2/stardiv/applet/AppletExecutionContext.java @@ -0,0 +1,415 @@ +/************************************************************************* + * + * $RCSfile: AppletExecutionContext.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package stardiv.applet; + +import java.applet.Applet; +import java.applet.AppletStub; +import java.applet.AppletContext; +import java.applet.AudioClip; + +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Panel; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; + +import java.net.URL; +import java.net.MalformedURLException; + +import java.util.Hashtable; +import java.util.Vector; + +import sun.misc.Queue; + +import com.sun.star.lib.sandbox.ClassContextProxy; +import com.sun.star.lib.sandbox.ExecutionContext; +import com.sun.star.lib.sandbox.JarEntry; +import com.sun.star.lib.sandbox.ResourceProxy; + +import com.sun.star.lib.sandbox.CodeSource; +import com.sun.star.lib.sandbox.PermissionCollection; +import com.sun.star.lib.sandbox.ProtectionDomain; +import com.sun.star.lib.sandbox.RuntimePermission; +import com.sun.star.lib.sandbox.FilePermission; +import com.sun.star.lib.sandbox.SocketPermission; + + +public final class AppletExecutionContext extends ExecutionContext + implements AppletStub, LiveConnectable +{ + private static final boolean DEBUG = false; // Enable / disable debug output + + private Applet applet; + private Container container; + + private DocumentProxy documentProxy; + private Hashtable parameters; + + private String className; + private Vector jarResourceProxys = new Vector(); + + private URL documentURL = null; + private URL baseURL = null; + + private ProtectionDomain protectionDomain; + private PermissionCollection permissionCollection; + + private java.awt.Toolkit toolkit; + + //************** C++ WRAPPER ****************** + private long pCppJSbxObject; + + synchronized public void ClearNativeHandle() { + pCppJSbxObject = 0; + if(DEBUG)System.err.println("### AppletExecutionContext.ClearNativeHandle"); + } + + public AppletExecutionContext(long pCppJSbxObject) { + this.pCppJSbxObject = pCppJSbxObject; + } + //************** C++ WRAPPER ****************** + + public AppletExecutionContext( URL documentURL, + Hashtable parameters, + Container container, + long pCppJSbxObject) + { + this(pCppJSbxObject); + + if(DEBUG) System.err.println("#### AppletExecutionContext.<init>:" + documentURL + " " + parameters + " " + container + " " + pCppJSbxObject); + this.documentURL = documentURL; + this.parameters = parameters; + this.container = container; + + toolkit = container.getToolkit(); + + documentProxy = DocumentProxy.getDocumentProxy(documentURL, toolkit); + addObserver(documentProxy); + } + + public void init() { + baseURL = null; + + try { + String codeBase = getParameter("codebase"); + + if (!codeBase.endsWith("/")) { + codeBase += "/"; + } + baseURL = new URL(documentURL, codeBase); + } + catch (Exception e) { + try { + String file = documentURL.getFile(); + int i = file.lastIndexOf('/'); + + if (i > 0 && i < file.length() - 1) { + baseURL = new URL(documentURL, file.substring(0, i + 1)); + } + } + catch (Exception e2) { + baseURL = documentURL; + } + } + + if(baseURL == null) + baseURL = documentURL; + + className = getParameter("code"); + String defaultExtension = ".class"; + String oldExtension = ".java"; + + int extensionIndex = className.lastIndexOf('.'); + String extension = ""; + + if (extensionIndex != -1) { + extension = className.substring(extensionIndex); + + if(!extension.equals(defaultExtension) && !extension.equals(oldExtension)) { + extension = defaultExtension; + } + else + className = className.substring(0, extensionIndex); + } + + String nm = "applet-" + className; + + documentProxy.addExecutionContext(this, className); + + permissionCollection = new PermissionCollection(); + protectionDomain = new ProtectionDomain(new CodeSource(baseURL, null), permissionCollection); + + super.init(nm, ClassContextProxy.create(baseURL, protectionDomain, null)); + + permissionCollection.add(new RuntimePermission("modifyThreadGroup", getThreadGroup())); + permissionCollection.add(new SocketPermission(SocketPermission.NETWORK_APPLET, baseURL.getHost())); + + try { + if(baseURL.getProtocol().equals("file")) // allow read acces for applet directory + permissionCollection.add(new FilePermission(new File(baseURL.getFile()).getCanonicalPath(), "read")); + } + catch(IOException eio) { + } + } + + void sDispose(long timeout) { + if(DEBUG) System.err.println("#### AppletExecutionContext.sDispose"); + + container = null; + jarResourceProxys = null; + + super.dispose(timeout); + } + + public void dispose(long timeout) { + sDispose(timeout); // call direct + +/* Deadlock with TKT + class DisposeEvent extends java.awt.AWTEvent + implements java.awt.peer.ActiveEvent, + java.awt.ActiveEvent + { + private AppletExecutionContext executionContext; + private long timeout; + + public DisposeEvent(AppletExecutionContext executionContext, long timeout) { + super(executionContext, 0); + + this.executionContext = executionContext; + this.timeout = timeout; + } + + public void dispatch() { + executionContext.sDispose(timeout); + } + } + + toolkit.getSystemEventQueue().postEvent(new DisposeEvent(this, timeout)); +*/ + } + + protected int getIntParameter(String name) { + int value = 0; + String string = getParameter(name); + if(string != null) + value = Integer.valueOf(string).intValue(); + + return value; + } + + protected void xload() + throws ClassNotFoundException, + InstantiationException, + IllegalAccessException + { + String archives = getParameter("archive"); + + try { + if(archives != null) { + int index = archives.indexOf(","); + while(index > -1) { + try { // try to load archive + loadArchive(archives.substring(0, index)); + } + catch(MalformedURLException malformedURLException) { + System.err.println("#### can't load archive:" + archives.substring(0, index)); + } + catch(IOException ioException) { + System.err.println("#### can't load archive:" + archives.substring(0, index) + " reason:" + ioException); + } + + archives = archives.substring(index + 1).trim(); + + index = archives.indexOf(","); + } + if(archives.length() > 0) loadArchive(archives); + } + + Class appletClass = classContext.loadClass(className); + synchronized(className) { + applet = (Applet)appletClass.newInstance(); + applet.setStub(this); + className.notifyAll(); + } + } + catch(IOException eio) { + throw new ClassNotFoundException(eio.getMessage()); + } + } + + protected void xinit() { + java.awt.Dimension size = new Dimension(getIntParameter("width"), getIntParameter("height")); + + container.setLayout(null); + container.setVisible(true); + container.setSize(size); + container.add(applet); + + applet.setVisible(false); + applet.setSize(size); + + container.validate(); + + applet.init(); + } + + protected void xstart() { + applet.setVisible(true); + container.validate(); + + applet.start(); + } + + protected void xstop() { + applet.stop(); + } + + protected void xdestroy() { + applet.destroy(); + applet.setVisible(false); + applet.setStub(null); + + documentProxy.removeExecutionContext(applet.getClass().getName()); + } + + protected void xdispose() { + if(container != null) + container.remove(applet); + + applet = null; + } + + private void loadArchive(String archive) throws MalformedURLException, IOException { + ResourceProxy jarResourceProxy = ResourceProxy.load(new URL(baseURL, archive), protectionDomain); + jarResourceProxy.loadJar(baseURL); + jarResourceProxys.addElement(jarResourceProxy); + } + + public Applet getApplet() { + synchronized(className) { + if(applet == null) { + if(DEBUG)System.err.println("#### AppletExecutionContext.getApplet - waiting for applet"); + try { + className.wait(); + } + catch(InterruptedException interruptedException) { + System.err.println("#### AppletExecutionContext.getApplet:" + interruptedException); + } + if(DEBUG)System.err.println("#### AppletExecutionContext.getApplet - got it"); + } + } + return applet; + } + + /* + * Methods for AppletStub interface + */ + public void appletResize(int width, int height) { + applet.setSize(new java.awt.Dimension(width, height)); + } + + public AppletContext getAppletContext() { + return documentProxy; + } + + public URL getCodeBase() { + return classContext.getBase(); + } + + public URL getDocumentBase() { + return documentProxy.getDocumentBase(); + } + + public String getParameter(String name) { + String string = (String)parameters.get(name.toLowerCase()); + if(string != null) + string = string.trim(); + + return string; + } + + public boolean isActive() { + return getStatus() == STARTED && pCppJSbxObject != 0; + } + + public void finalize() { + if(DEBUG) System.err.println("#### AppletExecutionContext finalized"); + } + + // sollte eigentlich im DocumentProxy sein, geht aber nicht + private native void xshowStatus(String status); + private native void xshowDocument(URL url, String aTarget); + + void printStatus(String status) { + if(pCppJSbxObject != 0) xshowStatus(status); + } + + void printDocument(URL url, String aTarget) { + if(pCppJSbxObject != 0) xshowDocument(url, aTarget); + } + + native public Object getJavaScriptJSObjectWindow(); +} diff --git a/sj2/stardiv/applet/Document.java b/sj2/stardiv/applet/Document.java new file mode 100644 index 000000000000..7264a5420c80 --- /dev/null +++ b/sj2/stardiv/applet/Document.java @@ -0,0 +1,182 @@ +/************************************************************************* + * + * $RCSfile: Document.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +package stardiv.applet; + +import java.awt.Image; + +// import java.applet.Applet; +// import java.applet.AppletContext; +// import java.applet.AudioClip; + + +import java.io.IOException; + +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Observer; +import java.util.Observable; + +import java.net.URL; + +import java.applet.Applet; +import java.applet.AppletContext; +import java.applet.AudioClip; + +import com.sun.star.lib.sandbox.ExecutionContext; +import com.sun.star.lib.sandbox.ResourceProxy; + +class Document implements LiveConnectable { + private Hashtable executionContexts = new Hashtable(); + private URL documentBase = null; + private java.awt.Toolkit toolkit; + + Document(URL url, java.awt.Toolkit toolkit) { + documentBase = url; + this.toolkit = toolkit; + } + + void addExecutionContext(ExecutionContext executionContext, String name) { + executionContexts.put(name, executionContext); + } + + void removeExecutionContext(String name) { + executionContexts.remove(name); + } + + Enumeration getExecutionContexts() { + return executionContexts.elements(); + } + + URL getDocumentBase() { + return documentBase; + } + + ExecutionContext getExecutionContext(String name) { + return (ExecutionContext)executionContexts.get(name); + } + + Enumeration getExcutionContexts() { + return executionContexts.elements(); + } + + /** + * Get the javascript environment for this applet. + */ + /* + public native Object getJavaScriptJSObjectWindow(); + public native void appletResize( int width, int height ); + public native void showDocument( URL url, String aTarget ); + public native void showStatus( String status ); + */ + + public AudioClip getAudioClip(URL url) { + ResourceProxy resourceProxy = ResourceProxy.load(url, null); + AudioClip audioClip = resourceProxy.getAudioClip(); + + return audioClip; + } + + public Image getImage(URL url) { + ResourceProxy resourceProxy = ResourceProxy.load(url, null); + Image image = toolkit.createImage(resourceProxy.getImageProducer()); + + return image; + } + + AppletExecutionContext getAppletExecutionContext() { + AppletExecutionContext appletExecutionContext = null; + + for(Enumeration e = executionContexts.elements(); e.hasMoreElements();) { + Object object = e.nextElement(); + if(object instanceof AppletExecutionContext) { + appletExecutionContext = (AppletExecutionContext)object; + } + } + return appletExecutionContext; + } + + + void showDocument(URL url, String aTarget) { + AppletExecutionContext appletExecutionContext = getAppletExecutionContext(); + if(appletExecutionContext != null) appletExecutionContext.printDocument(url, aTarget); + } + + public void showDocument(URL url) { + showDocument(url, "_top"); + } + + void showStatus(String status) { + status = (status == null) ? "" : status; + + AppletExecutionContext appletExecutionContext = getAppletExecutionContext(); + if(appletExecutionContext != null) appletExecutionContext.printStatus(status); + } + + public Object getJavaScriptJSObjectWindow() { + Object object = null; + + AppletExecutionContext appletExecutionContext = getAppletExecutionContext(); + if(appletExecutionContext != null) + object = appletExecutionContext.getJavaScriptJSObjectWindow(); + + return object; + } +} diff --git a/sj2/stardiv/applet/DocumentProxy.java b/sj2/stardiv/applet/DocumentProxy.java new file mode 100644 index 000000000000..6ef4d5055c7e --- /dev/null +++ b/sj2/stardiv/applet/DocumentProxy.java @@ -0,0 +1,207 @@ +/************************************************************************* + * + * $RCSfile: DocumentProxy.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +package stardiv.applet; + +import java.awt.Toolkit; +import java.awt.Image; + +import java.applet.Applet; +import java.applet.AppletContext; +import java.applet.AudioClip; + +import java.io.IOException; + +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Observer; +import java.util.Observable; + +import java.net.URL; + +import com.sun.star.lib.sandbox.Cachable; +import com.sun.star.lib.sandbox.ExecutionContext; +import com.sun.star.lib.sandbox.WeakRef; +import com.sun.star.lib.sandbox.WeakTable; +import com.sun.star.lib.sandbox.ResourceProxy; + +public class DocumentProxy implements AppletContext, Cachable, Observer, LiveConnectable { + static private int instances; + + synchronized static public DocumentProxy getDocumentProxy(URL url, Toolkit toolkit) { + DocumentProxy documentProxy = (DocumentProxy)WeakTable.get("Document: " + url); + + if(documentProxy == null) { + documentProxy = new DocumentProxy(url, toolkit); + WeakTable.put("Document: " + url, documentProxy); + } + + return documentProxy; + } + + + /* + ** interface cachable methods + */ + private Document document; + private WeakRef weakRef; + + public DocumentProxy() { + instances ++; + } + + public Object getHardObject() { + return document; + } + + public void setWeakRef(WeakRef weakRef) { + document = (Document)weakRef.getRef(); + + weakRef.incRefCnt(); + this.weakRef = weakRef; + } + + public void finalize() { + weakRef.decRefCnt(); + instances --; + } + + /* + ** DocumentProxy methods + */ + private Toolkit toolkit; + + private DocumentProxy(URL url, Toolkit toolkit) { + this(); + document = new Document(url, toolkit); + } + + void addExecutionContext(ExecutionContext executionContext, String name) { + document.addExecutionContext(executionContext, name); + } + + void removeExecutionContext(String name) { + document.removeExecutionContext(name); + } + + public URL getDocumentBase() { + return document.getDocumentBase(); + } + + /* + ** AppletContext interface methods + */ + public Applet getApplet(String name) { + return ((AppletExecutionContext)document.getExecutionContext(name)).getApplet(); + } + + public Enumeration getApplets() { + return new Enumeration() { + Enumeration contexts = document.getExecutionContexts(); + + public boolean hasMoreElements() { + return contexts.hasMoreElements(); + } + + public Object nextElement() { + return ((AppletExecutionContext)contexts.nextElement()).getApplet(); + } + }; + } + + public AudioClip getAudioClip(URL url) { + return document.getAudioClip(url); + } + + public Image getImage(URL url) { + return document.getImage(url); + } + + public void showDocument(URL url) { + document.showDocument(url); + } + + /** + * Get the javascript environment for this applet. + */ + /* + public native Object getJavaScriptJSObjectWindow(); + public native void appletResize( int width, int height ); + public native void showDocument( URL url, String aTarget ); + public native void showStatus( String status ); + */ + + public void showDocument(URL url, String aTarget) { + document.showDocument(url, aTarget); + } + + public void showStatus(String status) { + document.showStatus(status); + } + + public void update(Observable observable, Object object) { + showStatus((String)object); + } + + public Object getJavaScriptJSObjectWindow() { + return document.getJavaScriptJSObjectWindow(); + } +} + diff --git a/sj2/stardiv/applet/LiveConnectable.java b/sj2/stardiv/applet/LiveConnectable.java new file mode 100644 index 000000000000..9c33c09633c9 --- /dev/null +++ b/sj2/stardiv/applet/LiveConnectable.java @@ -0,0 +1,76 @@ +/************************************************************************* + * + * $RCSfile: LiveConnectable.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package stardiv.applet; + +/** + * LiveConnectable interface . + * + * @version 1.0, 21/04/98 + * @author Markus Meyer + */ + +public interface LiveConnectable +{ + public Object getJavaScriptJSObjectWindow(); +} + + diff --git a/sj2/stardiv/applet/makefile.mk b/sj2/stardiv/applet/makefile.mk new file mode 100644 index 000000000000..6adfa52db4e7 --- /dev/null +++ b/sj2/stardiv/applet/makefile.mk @@ -0,0 +1,110 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=sj2 +TARGET=applet + +PACKAGE=stardiv$/applet + +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +JARFILES= \ + sandbox.jar + +JAVAFILES=\ + AppletExecutionContext.java \ + Document.java \ + DocumentProxy.java \ + LiveConnectable.java + +#.IF "$(GUI)"=="WNT" +#JAVAFILES += WNativeAppletViewerFrame.java +#.ENDIF + +JAVACLASSFILES= \ + $(CLASSDIR)$/$(PACKAGE)$/DocumentProxy.class \ + $(CLASSDIR)$/$(PACKAGE)$/Document.class \ + $(CLASSDIR)$/$(PACKAGE)$/LiveConnectable.class \ + $(CLASSDIR)$/$(PACKAGE)$/AppletExecutionContext.class + + +#.IF "$(GUI)"=="WNT" +#JAVACLASSFILES += $(CLASSDIR)$/stardiv$/applet$/WNativeAppletViewerFrame.class +#.ENDIF + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +.INCLUDE : $(PRJ)$/util$/target.pmk + + + + + + + diff --git a/sj2/stardiv/applet/resources/MsgAppletViewer.java b/sj2/stardiv/applet/resources/MsgAppletViewer.java new file mode 100644 index 000000000000..d7e24350f63d --- /dev/null +++ b/sj2/stardiv/applet/resources/MsgAppletViewer.java @@ -0,0 +1,166 @@ +/************************************************************************* + * + * $RCSfile: MsgAppletViewer.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +package stardiv.applet.resources; + +import java.util.ListResourceBundle; + +public class MsgAppletViewer extends ListResourceBundle { + + public Object[][] getContents() { + return contents; + } + + static final Object[][] contents = { + {"textframe.button.dismiss", "Dismiss"}, + {"appletviewer.tool.title", "Applet Viewer: {0}"}, + {"appletviewer.menu.applet", "Applet"}, + {"appletviewer.menuitem.restart", "Restart"}, + {"appletviewer.menuitem.reload", "Reload"}, + {"appletviewer.menuitem.stop", "Stop"}, + {"appletviewer.menuitem.save", "Save..."}, + {"appletviewer.menuitem.start", "Start"}, + {"appletviewer.menuitem.clone", "Clone..."}, + {"appletviewer.menuitem.tag", "Tag..."}, + {"appletviewer.menuitem.info", "Info..."}, + {"appletviewer.menuitem.edit", "Edit"}, + {"appletviewer.menuitem.encoding", "Character Encoding"}, + {"appletviewer.menuitem.print", "Print..."}, + {"appletviewer.menuitem.props", "Properties..."}, + {"appletviewer.menuitem.close", "Close"}, + {"appletviewer.menuitem.quit", "Quit"}, + {"appletviewer.label.hello", "Hello..."}, + {"appletviewer.status.start", "starting applet..."}, + {"appletviewer.appletsave.err1", "serializing an {0} to {1}"}, + {"appletviewer.appletsave.err2", "in appletSave: {0}"}, + {"appletviewer.applettag", "Tag shown"}, + {"appletviewer.applettag.textframe", "Applet HTML Tag"}, + {"appletviewer.appletinfo.applet", "-- no applet info --"}, + {"appletviewer.appletinfo.param", "-- no parameter info --"}, + {"appletviewer.appletinfo.textframe", "Applet Info"}, + {"appletviewer.appletprint.printjob", "Print Applet"}, + {"appletviewer.appletprint.fail", "Printing failed."}, + {"appletviewer.appletprint.finish", "Finished printing."}, + {"appletviewer.appletprint.cancel", "Printing cancelled."}, + {"appletviewer.appletencoding", "Character Encoding: {0}"}, + {"appletviewer.init.err", "[no appletviewer.properties file found!]"}, + {"appletviewer.parse.warning.requiresname", "Warning: <param name=... value=...> tag requires name attribute."}, + {"appletviewer.parse.warning.paramoutside", "Warning: <param> tag outside <applet> ... </applet>."}, + {"appletviewer.parse.warning.requirescode", "Warning: <applet> tag requires code attribute."}, + {"appletviewer.parse.warning.requiresheight", "Warning: <applet> tag requires height attribute."}, + {"appletviewer.parse.warning.requireswidth", "Warning: <applet> tag requires width attribute."}, + {"appletviewer.parse.warning.appnotLongersupported", "Warning: <app> tag no longer supported, use <applet> instead:"}, + {"appletviewer.usage", "usage: appletviewer [-debug] [-J<javaflag>] [-encoding <character encoding type> ] url|file ..."}, + {"appletviewer.main.err.inputfile", "No input files specified."}, + {"appletviewer.main.err.badurl", "Bad URL: {0} ( {1} )"}, + {"appletviewer.main.err.io", "I/O exception while reading: {0}"}, + {"appletviewer.main.err.readablefile", "Make sure that {0} is a file and is readable."}, + {"appletviewer.main.err.correcturl", "Is {0} the correct URL?"}, + {"appletviewer.main.warning", "Warning: No Applets were started. Make sure the input contains an <applet> tag."}, + {"appletpanel.runloader.err", "Either object or code parameter!"}, + {"appletpanel.runloader.exception", "exception while deserializing {0}"}, + {"appletpanel.destroyed", "Applet destroyed."}, + {"appletpanel.loaded", "Applet loaded."}, + {"appletpanel.started", "Applet started."}, + {"appletpanel.inited", "Applet initialized."}, + {"appletpanel.stopped", "Applet stopped."}, + {"appletpanel.disposed", "Applet disposed."}, + {"appletpanel.nocode", "APPLET tag missing CODE parameter."}, + {"appletpanel.notfound", "load: class {0} not found."}, + {"appletpanel.nocreate", "load: {0} can''t be instantiated."}, + {"appletpanel.noconstruct", "load: {0} is not public or has no public constructor."}, + {"appletpanel.death", "killed"}, + {"appletpanel.exception", "exception: {0}."}, + {"appletpanel.exception2", "exception: {0}: {1}."}, + {"appletpanel.error", "error: {0}."}, + {"appletpanel.error2", "error: {0}: {1}."}, + {"appletpanel.notloaded", "Init: applet not loaded."}, + {"appletpanel.notinited", "Start: applet not initialized."}, + {"appletpanel.notstarted", "Stop: applet not started."}, + {"appletpanel.notstopped", "Destroy: applet not stopped."}, + {"appletpanel.notdestroyed", "Dispose: applet not destroyed."}, + {"appletpanel.notdisposed", "Load: applet not disposed."}, + {"appletpanel.bail", "Interrupted: bailing out."}, + {"appletpanel.filenotfound", "File not found when looking for: {0}"}, + {"appletpanel.fileformat", "File format exception when loading: {0}"}, + {"appletpanel.fileioexception", "I/O exception when loading: {0}"}, + {"appletpanel.fileexception", "{0} exception when loading: {1}"}, + {"appletpanel.filedeath", "{0} killed when loading: {1}"}, + {"appletpanel.fileerror", "{0} error when loading: {1}"}, + {"appletillegalargumentexception.objectinputstream", "AppletObjectInputStream requires non-null loader"}, + {"appletprops.title", "AppletViewer Properties"}, + {"appletprops.label.http.server", "Http proxy server:"}, + {"appletprops.label.http.proxy", "Http proxy port:"}, + {"appletprops.label.network", "Network access:"}, + {"appletprops.choice.network.item.none", "None"}, + {"appletprops.choice.network.item.applethost", "Applet Host"}, + {"appletprops.choice.network.item.unrestricted", "Unrestricted"}, + {"appletprops.label.class", "Class access:"}, + {"appletprops.choice.class.item.restricted", "Restricted"}, + {"appletprops.choice.class.item.unrestricted", "Unrestricted"}, + {"appletprops.label.unsignedapplet", "Allow unsigned applets:"}, + {"appletprops.choice.unsignedapplet.no", "No"}, + {"appletprops.choice.unsignedapplet.yes", "Yes"}, + {"appletprops.button.apply", "Apply"}, + {"appletprops.button.cancel", "Cancel"}, + {"appletprops.button.reset", "Reset"}, + {"appletprops.apply.exception", "Failed to save properties: {0}"}, + }; +} diff --git a/sj2/stardiv/applet/resources/makefile.mk b/sj2/stardiv/applet/resources/makefile.mk new file mode 100644 index 000000000000..bb272aa5d201 --- /dev/null +++ b/sj2/stardiv/applet/resources/makefile.mk @@ -0,0 +1,85 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=sj2 +TARGET=applet_resource + +PACKAGE=stardiv$/applet$/resources + +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +JAVAFILES=\ + MsgAppletViewer.java + +JAVACLASSFILES=\ + $(CLASSDIR)$/$(PACKAGE)$/MsgAppletViewer.class + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +.INCLUDE : $(PRJ)$/util$/target.pmk + diff --git a/sj2/stardiv/controller/SjSettings.java b/sj2/stardiv/controller/SjSettings.java new file mode 100644 index 000000000000..c5ab72b3d51d --- /dev/null +++ b/sj2/stardiv/controller/SjSettings.java @@ -0,0 +1,261 @@ +/************************************************************************* + * + * $RCSfile: SjSettings.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:03 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +package stardiv.controller; + +import java.util.Properties; +import java.util.Hashtable; +import java.util.Enumeration; + +import com.sun.star.lib.sandbox.SandboxSecurity; + +/** + * ber diese Klasse werden alle globalen Einstellungen, die fr das Sj Projekt + * wichtig sind, dokumentiert und modifiziert. + * + * @version $Version: 1.0 $ + * @author Markus Meyer + * + */ +public final class SjSettings { + /** + * The following properties are used to setup the environment for + * the stardiv packages.<BR> + * "appletviewer.security.mode"="unrestricted" | "host" | "none": Set the + * security level of the default SecurityManager. The default is "host".<BR> + * "stardiv.security.defaultSecurityManager"="true" | "false": Create and set + * the stardiv.security.AppletSecurity, if the property is "true". This occures + * only in the first call.<BR> + * "stardiv.security.noExit"="true" | "false": no exit is allowed. Use this property + * if you are running more than one java application in the virtual machine. This occures + * only in the first call.<BR> + * "stardiv.security.disableSecurity"="true" | "false": disable security checking. Only usefull + * if a SecurityManager is installed. The default is "false".<BR> + * if you are running more than one java application in the virtual machine. This occures + * only in the first call.<BR> + * "stardiv.controller.installConsole"="true" | "false": pipe the stdout and stderr + * through a console. Show the console with stardiv.controller.Console.showConsole( true ). + * This occures only in the first call.<BR> + * "stardiv.js.debugOnError"="true" | "false": Start the javascript ide, if an error + * occures. The default is "false".<BR> + * "stardiv.js.debugImmediate"="true" | "false": Start the javascript ide, if a script + * starts. The default is "false".<BR> + * "stardiv.debug.trace"="messageBox" | "window" | "file" | "none": The trace pipe is + * set to one of the four mediums. The Default is "none".<BR> + * "stardiv.debug.error"="messageBox" | "window" | "file" | "none": The error pipe is + * set to one of the four mediums. The Default is "none".<BR> + * "stardiv.debug.warning"="messageBox" | "window" | "file" | "none": The warning pipe is + * set to one of the four mediums. The Default is "none".<BR> + * If the properties http.proxyHost, http.proxyPort, http.maxConnections, + * http.keepAlive or http.nonProxyHosts are changed, the method + * sun.net.www.http.HttpClient.resetProperties() is called.<BR> + * If the properties ftpProxySet, ftpProxyHost or ftpProxyPort are changed, + * the static variables useFtpProxy, ftpProxyHost and ftpProxyPort in the class + * sun.net.ftp.FtpClient are set.<BR> + * <B>If you are writing your own SecurityManager and ClassLoader, please implement the + * interfaces stardiv.security.ClassLoaderExtension and + * stardiv.security.SecurityManagerExtension. Be shure to set the + * stardiv.security.ClassLoaderFactory, to enable dynamic class loading, otherwise + * the stardiv.security.AppletClassLoader is used. Set the factory with + * SjSettings.setClassLoaderFactory().</B> + */ + static public synchronized void changeProperties( Properties pChangeProps ) + { + SecurityManager pSM = System.getSecurityManager(); + if( pSM != null ) + pSM.checkPropertiesAccess(); + Properties props = new Properties( System.getProperties() ); + boolean bInited = Boolean.getBoolean( "stardiv.controller.SjSettings.inited" ); + + + if( !bInited ) + { + // check the awt.toolkit property: if none is set use com.sun.star.comp.jawt.peer.Toolkit + //if ( props.getProperty("awt.toolkit") == null ) + // props.put("awt.toolkit", "com.sun.star.comp.jawt.peer.Toolkit"); + + // Define a number of standard properties + props.put("acl.read", "+"); + props.put("acl.read.default", ""); + props.put("acl.write", "+"); + props.put("acl.write.default", ""); + + // Standard browser properties + props.put("browser", "stardiv.applet.AppletViewerFrame"); + props.put("browser.version", "4.02"); + props.put("browser.vendor", "Sun Microsystems, Inc."); + props.put("http.agent", "JDK/1.1"); + + // Define which packages can be accessed by applets + props.put("package.restrict.access.sun", "true"); + props.put("package.restrict.access.netscape", "true"); + props.put("package.restrict.access.stardiv", "true"); + + // Define which packages can be extended by applets + props.put("package.restrict.definition.java", "true"); + props.put("package.restrict.definition.sun", "true"); + props.put("package.restrict.definition.netscape", "true"); + props.put("package.restrict.definition.stardiv", "true"); + + // Define which properties can be read by applets. + // A property named by "key" can be read only when its twin + // property "key.applet" is true. The following ten properties + // are open by default. Any other property can be explicitly + // opened up by the browser user setting key.applet=true in + // ~/.hotjava/properties. Or vice versa, any of the following can + // be overridden by the user's properties. + props.put("java.version.applet", "true"); + props.put("java.vendor.applet", "true"); + props.put("java.vendor.url.applet", "true"); + props.put("java.class.version.applet", "true"); + props.put("os.name.applet", "true"); + props.put("os.version.applet", "true"); + props.put("os.arch.applet", "true"); + props.put("file.separator.applet", "true"); + props.put("path.separator.applet", "true"); + props.put("line.separator.applet", "true"); + + // das appletresourceprotokol + props.put("java.protocol.handler.pkgs", "stardiv.net.protocol"); + } + + boolean bHttpClientChanged = false; + boolean bFtpClientChanged = false; + boolean bSecurityChanged = false; + // detect changes + if( pChangeProps != null ) + { + bHttpClientChanged = + !equalsImpl( props.get( "http.proxyHost" ), pChangeProps.get( "http.proxyHost" ) ) + || !equalsImpl( props.get( "http.proxyPort" ), pChangeProps.get( "http.proxyPort" ) ) + || !equalsImpl( props.get( "http.maxConnections" ), pChangeProps.get( "http.maxConnections" ) ) + || !equalsImpl( props.get( "http.keepAlive" ), pChangeProps.get( "http.keepAlive" ) ) + || !equalsImpl( props.get( "http.nonProxyHosts" ), pChangeProps.get( "http.nonProxyHosts" ) ); + bFtpClientChanged = + !equalsImpl( props.get( "ftpProxySet" ), pChangeProps.get( "ftpProxySet" ) ) + || !equalsImpl( props.get( "ftpProxyHost" ), pChangeProps.get( "ftpProxyHost" ) ) + || !equalsImpl( props.get( "ftpProxyPort" ), pChangeProps.get( "ftpProxyPort" ) ); + bSecurityChanged = + !equalsImpl( props.get( "appletviewer.security.mode" ), pChangeProps.get( "appletviewer.security.mode" ) ) + || !equalsImpl( props.get( "stardiv.security.disableSecurity" ), pChangeProps.get( "stardiv.security.disableSecurity" ) ); + } + + // put new and changed properties to the property table + if( pChangeProps != null ) + { + Enumeration aEnum = pChangeProps.propertyNames(); + while( aEnum.hasMoreElements() ) + { + String aKey = (String)aEnum.nextElement(); + props.put( aKey, pChangeProps.getProperty( aKey ) ); + } + } + + // Install a property list. + if( !bInited ) + props.put( "stardiv.controller.SjSettings.inited", "true" ); + System.setProperties(props); + if( !bInited ) + { + // Security Manager setzten + if( Boolean.getBoolean( "stardiv.security.defaultSecurityManager" ) ) + { + boolean bNoExit = Boolean.getBoolean( "stardiv.security.noExit" ); + //Create and install the security manager + System.setSecurityManager(new SandboxSecurity(bNoExit)); + } + if( Boolean.getBoolean("stardiv.controller.installConsole") ) + Console.installConsole(); + + } + // Not Documented, setting a try catch, for IncompatibleClassChangeException. + try + { + if( bHttpClientChanged ) + sun.net.www.http.HttpClient.resetProperties(); + if( bFtpClientChanged ) + { + sun.net.ftp.FtpClient.useFtpProxy = Boolean.getBoolean("ftpProxySet"); + sun.net.ftp.FtpClient.ftpProxyHost = System.getProperty("ftpProxyHost"); + sun.net.ftp.FtpClient.ftpProxyPort = Integer.getInteger("ftpProxyPort", 80).intValue(); + } + } + catch( Throwable e ) + { + } + if( bSecurityChanged ) + { + pSM = System.getSecurityManager(); + if( pSM instanceof SandboxSecurity ) + { + ((SandboxSecurity)pSM).reset(); + } + } + } + + private static boolean equalsImpl( Object p1, Object p2 ) + { + return p1 == p2 || (p1 != null && p2 != null && p1.equals( p2 ) ); + } +} + + + diff --git a/sj2/stardiv/controller/makefile.mk b/sj2/stardiv/controller/makefile.mk new file mode 100644 index 000000000000..6a2b2402cf1a --- /dev/null +++ b/sj2/stardiv/controller/makefile.mk @@ -0,0 +1,102 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:54:04 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=sj2 +TARGET=controller + +PACKAGE=stardiv$/controller +JARFILES=sandbox.jar tkt.jar + +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +JAVAFILES= \ + SjSettings.java \ + StreamObserver.java \ + NativeStreamObserver.java \ + AppStarter.java \ + AppStarterStatus.java \ + AppStarterStatusNative.java \ + JavaSystemMonitor.java \ + Console.java \ + PropertyEditor.java + +JAVACLASSFILES= \ + $(CLASSDIR)$/$(PACKAGE)$/SjSettings.class \ + $(CLASSDIR)$/$(PACKAGE)$/StreamObserver.class \ + $(CLASSDIR)$/$(PACKAGE)$/NativeStreamObserver.class \ + $(CLASSDIR)$/$(PACKAGE)$/AppStarter.class \ + $(CLASSDIR)$/$(PACKAGE)$/AppStarterStatus.class \ + $(CLASSDIR)$/$(PACKAGE)$/AppStarterStatusNative.class \ + $(CLASSDIR)$/$(PACKAGE)$/Console.class \ + $(CLASSDIR)$/$(PACKAGE)$/JavaSystemMonitor.class \ + $(CLASSDIR)$/$(PACKAGE)$/PropertyEditor.class + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +.INCLUDE : $(PRJ)$/util$/target.pmk + diff --git a/sj2/stardiv/security/resources/MsgAppletViewer.java b/sj2/stardiv/security/resources/MsgAppletViewer.java new file mode 100644 index 000000000000..d02ce8184216 --- /dev/null +++ b/sj2/stardiv/security/resources/MsgAppletViewer.java @@ -0,0 +1,122 @@ +/************************************************************************* + * + * $RCSfile: MsgAppletViewer.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:54:04 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +package stardiv.security.resources; + +import java.util.ListResourceBundle; + +/* Alle Resourcen aus AppletClassLoader, Applet und AppletSecurityException. +*/ +public class MsgAppletViewer extends ListResourceBundle { + + public Object[][] getContents() { + return contents; + } + + static final Object[][] contents = { + {"appletclassloader.loadcode.verbose", "Opening stream to: {0} to get {1}"}, + {"appletclassloader.filenotfound", "File not found when looking for: {0}"}, + {"appletclassloader.fileformat", "File format exception when loading: {0}"}, + {"appletclassloader.fileioexception", "I/O exception when loading: {0}"}, + {"appletclassloader.fileexception", "{0} exception when loading: {1}"}, + {"appletclassloader.filedeath", "{0} killed when loading: {1}"}, + {"appletclassloader.fileerror", "{0} error when loading: {1}"}, + {"appletclassloader.findclass.verbose.findclass", "{0} find class {1}"}, + {"appletclassloader.findclass.verbose.openstream", "Opening stream to: {0} to get {1}"}, + {"appletclassloader.getresource.verbose.forname", "AppletClassLoader.getResource for name: {0}"}, + {"appletclassloader.getresource.verbose.found", "Found resource: {0} as a system resource"}, + {"appletclassloader.getresourceasstream.verbose", "Found resource: {0} as a system resource"}, + {"appletioexception.loadclass.throw.interrupted", "class loading interrupted: {0}"}, + {"appletioexception.loadclass.throw.notloaded", "class not loaded: {0}"}, + {"appletsecurityexception.checkcreateclassloader", "Security Exception: classloader"}, + {"appletsecurityexception.checkaccess.thread", "Security Exception: thread"}, + {"appletsecurityexception.checkaccess.threadgroup", "Security Exception: threadgroup: {0}"}, + {"appletsecurityexception.checkexit", "Security Exception: exit: {0}"}, + {"appletsecurityexception.checkexec", "Security Exception: exec: {0}"}, + {"appletsecurityexception.checklink", "Security Exception: link: {0}"}, + {"appletsecurityexception.checkpropsaccess", "Security Exception: properties"}, + {"appletsecurityexception.checkpropsaccess.key", "Security Exception: properties access {0}"}, + {"appletsecurityexception.checkread.exception1", "Security Exception: {0}, {1}"}, + {"appletsecurityexception.checkread.exception2", "Security Exception: file.read: {0}"}, + {"appletsecurityexception.checkread", "Security Exception: file.read: {0} == {1}"}, + {"appletsecurityexception.checkwrite.exception", "Security Exception: {0}, {1}"}, + {"appletsecurityexception.checkwrite", "Security Exception: file.write: {0} == {1}"}, + {"appletsecurityexception.checkread.fd", "Security Exception: fd.read"}, + {"appletsecurityexception.checkwrite.fd", "Security Exception: fd.write"}, + {"appletsecurityexception.checklisten", "Security Exception: socket.listen: {0}"}, + {"appletsecurityexception.checkaccept", "Security Exception: socket.accept: {0}:{1}"}, + {"appletsecurityexception.checkconnect.networknone", "Security Exception: socket.connect: {0}->{1}"}, + {"appletsecurityexception.checkconnect.networkhost1", "Security Exception: Couldn''t connect to {0} with origin from {1}."}, + {"appletsecurityexception.checkconnect.networkhost2", "Security Exception: Couldn''t resolve IP for host {0} or for {1}. "}, + {"appletsecurityexception.checkconnect.networkhost3", "Security Exception: Could not resolve IP for host {0}. See the trustProxy property."}, + {"appletsecurityexception.checkconnect", "Security Exception: connect: {0}->{1}"}, + {"appletsecurityexception.checkpackageaccess", "Security Exception: cannot access package: {0}"}, + {"appletsecurityexception.checkpackagedefinition", "Security Exception: cannot define package: {0}"}, + {"appletsecurityexception.cannotsetfactory", "Security Exception: cannot set factory"}, + {"appletsecurityexception.checkmemberaccess", "Security Exception: check member access"}, + {"appletsecurityexception.checkgetprintjob", "Security Exception: getPrintJob"}, + {"appletsecurityexception.checksystemclipboardaccess", "Security Exception: getSystemClipboard"}, + {"appletsecurityexception.checkawteventqueueaccess", "Security Exception: getEventQueue"}, + {"appletsecurityexception.checksecurityaccess", "Security Exception: security operation: {0}"}, + {"appletsecurityexception.getsecuritycontext.unknown", "unknown class loader type. unable to check for getContext"}, + {"appletsecurityexception.checkread.unknown", "unknown class loader type. unable to check for checking read {0}"}, + {"appletsecurityexception.checkconnect.unknown", "unknown class loader type. unable to check for checking connect"}, + }; +} diff --git a/sj2/stardiv/security/resources/makefile.mk b/sj2/stardiv/security/resources/makefile.mk new file mode 100644 index 000000000000..44bfeb2ec5a0 --- /dev/null +++ b/sj2/stardiv/security/resources/makefile.mk @@ -0,0 +1,85 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:54:04 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=sj2 +TARGET=security_resource + +PACKAGE=stardiv$/security$/resources + +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +JAVAFILES=\ + MsgAppletViewer.java + +JAVACLASSFILES=\ + $(CLASSDIR)$/stardiv$/security$/resources$/MsgAppletViewer.class + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +.INCLUDE : $(PRJ)$/util$/target.pmk + diff --git a/sj2/util/makefile.mk b/sj2/util/makefile.mk new file mode 100644 index 000000000000..14d238d98eb1 --- /dev/null +++ b/sj2/util/makefile.mk @@ -0,0 +1,138 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:54:04 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=.. + +PRJNAME=sj2 +TARGET=sj +USE_LDUMP2=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +LDUMP2=LDUMP3 + +# ------------------------------------------------------------------ + +.IF "$(header)" == "" + +LIB1TARGET= $(SLB)$/$(TARGET).lib +LIB1FILES= \ + $(SLB)$/java.lib \ + $(SLB)$/jscpp.lib + +SHL1DEPN= $(L)$/itools.lib $(SVLIBDEPEND) $(L)$/svtool.lib $(LIB1TARGET) + +SHL1TARGET= j$(UPD)$(DLLPOSTFIX)_g +SHL1IMPLIB= $(TARGET) + +SHL1STDLIBS= \ + $(SVTOOLLIB) \ + $(SVLLIB) \ + $(TKLIB) \ + $(VCLLIB) \ + $(TOOLSLIB) \ + $(VOSLIB) \ + $(SALLIB) \ + $(RTLLIB) \ + $(CPPULIB) \ + $(UNOTOOLSLIB) + +SHL1LIBS= $(SLB)$/$(TARGET).lib +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME =$(SHL1TARGET) +DEF1DEPN =$(MISC)$/$(SHL1TARGET).flt +DEFLIB1NAME =$(TARGET) +DEF1DES =JavaCPP +DEF1CEXP =Java +.ENDIF + +JARTARGET=classes.jar +JARCLASSDIRS=stardiv + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk +.INCLUDE : target.pmk + +$(MISC)$/$(SHL1TARGET).flt: makefile.mk + @echo ------------------------------ + @echo Making: $@ + @echo WEP>$@ + @echo LIBMAIN>>$@ + @echo LibMain>>$@ + @echo bad_alloc::bad_alloc>>$@ + @echo exception::exception>>$@ +.IF "$(COM)"=="MSC" + @echo __CT>>$@ +.ENDIF +.IF "$(COM)"=="ICC" + @echo __lower_bound>>$@ + @echo __stl_prime>>$@ + @echo __alloc>>$@ + @echo __malloc>>$@ +.ENDIF + diff --git a/sj2/util/makefile.pmk b/sj2/util/makefile.pmk new file mode 100644 index 000000000000..f36e7c0312de --- /dev/null +++ b/sj2/util/makefile.pmk @@ -0,0 +1,85 @@ +#************************************************************************* +# +# $RCSfile: makefile.pmk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:54:04 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +#PROJECTPCH4DLL=TRUE +#PROJECTPCH=sjpch +#PROJECTPCHSOURCE=$(PRJ)$/util\sjpch +#PDBTARGET=sj +PRJPCH= + +JAVAPREPRO= +.IF "$(JDK_VERSION)" == "110" +JAVAPREPRO=-jdk11 +.ENDIF +.IF "$(PRODUCT)" != "" +JAVAPREPRO=$(JAVAPREPRO) + " -product" +.ENDIF + +ENABLE_EXCEPTIONS=TRUE + +JARFILES=sandbox.jar tkt.jar + +# --- Settings ----------------------------------------------------- +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + diff --git a/sj2/util/target.pmk b/sj2/util/target.pmk new file mode 100644 index 000000000000..af6cc99902a7 --- /dev/null +++ b/sj2/util/target.pmk @@ -0,0 +1,73 @@ +#************************************************************************* +# +# $RCSfile: target.pmk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:54:04 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* +.IF "$(depend)" == "" +ONLYZIP: $(SLOFILES) + cd $(PRJ)$/util + nmake debug=t + +TEST: + +DOC: + +PREPRO: + $(JAVAI) $(JAVACPS) $(CLASSPATH) stardiv.app.Javac $(JAVAPREPRO) $(JAVAFILES) +.ENDIF |