8190378: Removal of CORBA and Java EE modules

Reviewed-by: rriggs, alanb, mchung, erikj, goetz
This commit is contained in:
Lance Andersen 2018-02-10 07:06:16 -05:00
parent 7c4ed0b15b
commit 987c3a2d87
5178 changed files with 221 additions and 805798 deletions

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -69,8 +69,6 @@ $(eval $(call SetupJavaCompilation, BUILD_jdk.rmic.interim, \
COPY := .properties, \
ADD_JAVAC_FLAGS := \
--module-path $(BUILDTOOLS_OUTPUTDIR)/interim_rmic_modules \
--add-modules java.corba \
--add-exports java.corba/com.sun.corba.se.impl.util=jdk.rmic.interim \
$(INTERIM_RMIC_ADD_EXPORTS), \
))

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -38,10 +38,6 @@ $(eval $(call IncludeCustomExtension, CompileJavaModules.gmk))
################################################################################
# Module specific build settings
java.activation_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
################################################################################
java.base_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' -XDstringConcat=inline
java.base_COPY += .icu .dat .spp content-types.properties hijrah-config-islamic-umalqura.properties
java.base_CLEAN += intrinsic.properties
@ -256,10 +252,6 @@ java.prefs_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,
################################################################################
java.transaction_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*'
################################################################################
java.sql_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*'
java.sql_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
@ -279,27 +271,6 @@ java.rmi_CLEAN_FILES += $(wildcard \
################################################################################
java.corba_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
java.corba_COPY += .prp
java.corba_CLEAN += .properties
java.corba_EXCLUDES += \
com/sun/corba/se/PortableActivationIDL \
com/sun/tools/corba/se/logutil \
#
java.corba_EXCLUDE_FILES += \
com/sun/corba/se/impl/presentation/rmi/JNDIStateFactoryImpl.java \
com/sun/corba/se/spi/presentation/rmi/StubWrapper.java \
com/sun/org/omg/CORBA/IDLTypeOperations.java \
com/sun/org/omg/CORBA/IRObjectOperations.java \
org/omg/PortableInterceptor/UNKNOWN.java \
com/sun/tools/corba/se/idl/ResourceBundleUtil.java \
com/sun/corba/se/impl/presentation/rmi/jndi.properties \
#
################################################################################
java.xml_ADD_JAVAC_FLAGS += -Xdoclint:all/protected \
'-Xdoclint/package:$(call CommaList, javax.xml.catalog javax.xml.datatype \
javax.xml.transform javax.xml.validation javax.xml.xpath)'
@ -307,32 +278,11 @@ java.xml_CLEAN += .properties
################################################################################
java.xml.bind_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
java.xml.bind_CLEAN += .properties
################################################################################
java.xml.soap_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
java.xml.soap_CLEAN += .properties
################################################################################
java.xml.ws_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
java.xml.ws_COPY += .xml
java.xml.ws_CLEAN += .properties
################################################################################
java.naming_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' -Xlint:-exports
java.naming_CLEAN += jndiprovider.properties
################################################################################
java.security.saaj_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*'
java.security.saaj_CLEAN += .properties
################################################################################
java.security.jgss_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*'
################################################################################
@ -553,17 +503,6 @@ jdk.aot_ADD_JAVAC_FLAGS += -parameters -XDstringConcat=inline \
################################################################################
jdk.xml.bind_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
jdk.xml.bind_CLEAN += .properties
jdk.xml.bind_COPY += .xsd JAXBContextFactory.java ZeroOneBooleanAdapter.java
################################################################################
jdk.xml.ws_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
jdk.xml.ws_CLEAN += .properties
################################################################################
sun.charsets_COPY += .dat
################################################################################

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -53,9 +53,7 @@ $(eval $(call SetupJavaCompilation,BUILD_TOOLS_JDK, \
, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes, \
ADD_JAVAC_FLAGS := \
--add-modules java.xml.bind \
--add-exports java.desktop/sun.awt=ALL-UNNAMED \
--add-exports java.xml.bind/javax.xml.bind.annotation=ALL-UNNAMED \
--add-exports java.base/sun.text=ALL-UNNAMED \
, \
))

View file

@ -44,7 +44,7 @@ $(eval $(call IncludeCustomExtension, Docs.gmk))
#
# We will generate API documentation for two different selections of the source
# code: "Java SE", which contains just the modules covered by the top-level
# module java.se.ee, and "JDK", which covers all of Java SE and also all
# module java.se and "JDK", which covers all of Java SE and also all
# other available modules that should be documented, including imported modules,
# if any.
#
@ -396,8 +396,8 @@ endef
# Define the groups of the JDK API documentation
JavaSE_GROUP_NAME := Java SE
JavaSE_GROUP_MODULES := $(call ColonList, $(sort java.se.ee \
$(call FindTransitiveIndirectDepsForModules, java.se.ee)))
JavaSE_GROUP_MODULES := $(call ColonList, $(sort java.se \
$(call FindTransitiveIndirectDepsForModules, java.se)))
JavaSE_GROUP_DESCRIPTION := \
The Java Platform, Standard Edition (Java SE) APIs define the core Java \
platform for general-purpose computing. These APIs are in modules whose \

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -199,7 +199,6 @@ ifneq ($(OPENJDK_TARGET_OS), windows)
rmid.1 \
rmiregistry.1 \
servertool.1 \
tnameserv.1 \
unpack200.1
JDK_MAN_PAGES += \
@ -223,11 +222,7 @@ ifneq ($(OPENJDK_TARGET_OS), windows)
jstat.1 \
jstatd.1 \
rmic.1 \
schemagen.1 \
serialver.1 \
wsgen.1 \
wsimport.1 \
xjc.1
serialver.1
# This variable is potentially overridden in the closed makefile.
MAN_SRC_BASEDIR ?= $(TOPDIR)/src

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -124,10 +124,9 @@ ifneq ($(CREATING_BUILDJDK), true)
LANGTOOLS_GENSRC_TARGETS := $(filter $(addsuffix -%, $(LANGTOOLS_MODULES)), $(GENSRC_TARGETS))
INTERIM_LANGTOOLS_GENSRC_TARGETS := $(filter $(addsuffix -%, \
$(INTERIM_LANGTOOLS_BASE_MODULES)), $(GENSRC_TARGETS))
CORBA_GENSRC_TARGETS := $(filter $(addsuffix -%, $(CORBA_MODULES)), $(GENSRC_TARGETS))
HOTSPOT_GENSRC_TARGETS := $(filter $(addsuffix -%, $(HOTSPOT_MODULES)), $(GENSRC_TARGETS))
JDK_GENSRC_TARGETS := $(filter-out $(LANGTOOLS_GENSRC_TARGETS) \
$(CORBA_GENSRC_TARGETS) $(HOTSPOT_GENSRC_TARGETS), $(GENSRC_TARGETS))
$(HOTSPOT_GENSRC_TARGETS), $(GENSRC_TARGETS))
GENSRC_MODULEINFO_MODULES := $(ALL_MODULES)
GENSRC_MODULEINFO_TARGETS := $(addsuffix -gensrc-moduleinfo, \
@ -618,8 +617,6 @@ else
buildtools-modules: exploded-image-base
$(CORBA_GENSRC_TARGETS): interim-langtools
$(HOTSPOT_GENSRC_TARGETS): interim-langtools buildtools-hotspot
$(JDK_GENSRC_TARGETS): interim-langtools buildtools-jdk

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -92,7 +92,6 @@ TOOL_SPP = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes build.too
# Nimbus is used somewhere in the swing build.
TOOL_GENERATENIMBUS = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
--add-modules java.xml.bind \
build.tools.generatenimbus.Generator
TOOL_WRAPPERGENERATOR = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \

View file

@ -629,14 +629,11 @@ JAVADOC_MAIN_CLASS = -m jdk.javadoc.interim/jdk.javadoc.internal.tool.Main
INTERIM_RMIC_BASE_MODULES := jdk.rmic
INTERIM_RMIC_MODULES := $(addsuffix .interim, $(INTERIM_RMIC_BASE_MODULES))
INTERIM_RMIC_ADD_EXPORTS := \
--add-exports java.corba/com.sun.corba.se.impl.util=jdk.rmic.interim \
#
# Use = to delay expansion of PathList since it's not available in this file.
INTERIM_RMIC_ARGS = --limit-modules java.base,jdk.compiler,jdk.javadoc,java.corba \
INTERIM_RMIC_ARGS = --limit-modules java.base,jdk.compiler,jdk.javadoc \
--module-path $(call PathList, $(BUILDTOOLS_OUTPUTDIR)/interim_rmic_modules \
$(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules) \
$(INTERIM_RMIC_ADD_EXPORTS) \
#
# You run the new javac using the boot jdk with $(BOOT_JDK)/bin/java $(NEW_JAVAC) ...

View file

@ -1,113 +0,0 @@
#
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code 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 General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
PREFIXES=-pkgPrefix CORBA org.omg \
-pkgPrefix CosNaming org.omg \
-pkgPrefix CosTransactions org.omg \
-pkgPrefix CosTSInteroperation org.omg \
-pkgPrefix DynamicAny org.omg \
-pkgPrefix Dynamic org.omg \
-pkgPrefix IOP org.omg \
-pkgPrefix Messaging org.omg \
-pkgPrefix PortableInterceptor org.omg \
-pkgPrefix PortableServer org.omg \
-pkgPrefix activation com.sun.corba.se.spi \
-pkgPrefix GIOP com.sun.corba.se \
-pkgPrefix PortableActivationIDL com.sun.corba.se \
-pkgPrefix messages com.sun.corba.se
define add_idl_package
# param 1 = MYPACKAGE
# param 2 = src root
# param 3 = gensrc root
# param 4 = source idl to compile
# param 5 = target idl package
# param 6 = delete these files that were output from the idlj
# param 7 = idls that match these patterns should be compiled with -oldImplBase
# param 8 = the idlj command
# Save the generated java files to a temporary directory so
# that we can find them and create proper dependencies.
# After that, we move them to the real gensrc target dir.
$4_TMPDIR:=tmp___$(subst /,_,$(patsubst $2/%,%,$4))___
ifneq ($$(filter $7,$4),)
$4_OLDIMPLBASE:=-oldImplBase
$4_OLDIMPLBASE_MSG:=with -oldImplBase
endif
$5 : $4
$$(call LogInfo, Compiling IDL $(patsubst $2/%,%,$4))
$$(call MakeDir, $$(@D))
$(RM) -rf $3/$$($4_TMPDIR)
$8 -td $3/$$($4_TMPDIR) \
-i $2/org/omg/CORBA \
-i $2/org/omg/PortableInterceptor \
-i $2/org/omg/PortableServer \
-D CORBA3 -corba 3.0 \
-fall \
$$($4_OLDIMPLBASE) \
$(PREFIXES) \
$4
$(RM) -f $$(addprefix $3/$$($4_TMPDIR)/,$6)
$(CP) -r $3/$$($4_TMPDIR)/* $3
($(CD) $3/$$($4_TMPDIR) && $(FIND) . -type f | $(SED) 's!\./!$3/!g' | $(NAWK) '{ print $$$$1 ": $4" }' > $5)
$(RM) -rf $3/$$($4_TMPDIR)
endef
# Setup make rules for creating an IDL compilation.
#
# Parameter 1 is the name of the rule. This name is used as variable prefix,
# and the targets generated are listed in a variable by that name.
#
# Remaining parameters are named arguments. These include:
# IDLJ
# SRC
# BIN
# INCLUDES
# EXCLUDES
# OLDIMPLBASES
# DELETES
SetupIdlCompilation = $(NamedParamsMacroTemplate)
define SetupIdlCompilationBody
# Find all existing java files and existing class files.
$$(call MakeDir,$$($1_BIN))
$1_SRCS := $$(shell find $$($1_SRC) -name "*.idl")
$1_BINS := $$(shell find $$($1_BIN) -name "*.java")
# Prepend the source/bin path to the filter expressions.
$1_SRC_INCLUDES := $$(addprefix $$($1_SRC)/,$$($1_INCLUDES))
$1_SRC_EXCLUDES := $$(addprefix $$($1_SRC)/,$$($1_EXCLUDES))
$1_BIN_INCLUDES := $$(addprefix $$($1_BIN)/,$$($1_INCLUDES))
$1_BIN_EXCLUDES := $$(addprefix $$($1_BIN)/,$$($1_EXCLUDES))
$1_OLDIMPLBASES := $$(addprefix $$($1_SRC)/,$$($1_OLDIMPLBASES))
# Now remove unwanted java/class files.
$1_SRCS := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS))
$1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
$1_BINS := $$(filter $$($1_BIN_INCLUDES),$$($1_BINS))
$1_BINS := $$(filter-out $$($1_BIN_EXCLUDES),$$($1_BINS))
$1 := $$(sort $$(patsubst $$($1_SRC)/%.idl,$$($1_BIN)/%.idl.d,$$($1_SRCS)))
# Now create the dependencies for each idl target.
$$(foreach p,$$($1),$$(eval $$(call add_idl_package,$1,$$($1_SRC),$$($1_BIN),$$(patsubst $$($1_BIN)/%.idl.d,$$($1_SRC)/%.idl,$$p),$$p,$$($1_DELETES),$$($1_OLDIMPLBASES),$$($1_IDLJ))))
endef
.SUFFIXES: .java .class .package

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -74,24 +74,13 @@ BOOT_MODULES += \
# Modules that directly or indirectly requiring upgradeable modules
# should carefully be considered if it should be upgradeable or not.
UPGRADEABLE_MODULES += \
java.activation \
java.compiler \
java.corba \
java.transaction \
java.xml.bind \
java.xml.ws \
java.xml.ws.annotation \
jdk.internal.vm.compiler \
#
UPGRADEABLE_TOOL_MODULES += \
jdk.xml.bind \
jdk.xml.ws \
#
AGGREGATOR_MODULES += \
java.se \
java.se.ee \
#
PLATFORM_MODULES += \
@ -143,7 +132,7 @@ JRE_TOOL_MODULES += \
# DOCS_MODULES defines the root modules for javadoc generation.
# All of their `require transitive` modules directly and indirectly will be included.
DOCS_MODULES += \
java.se.ee \
java.se \
java.smartcardio \
jdk.accessibility \
jdk.attach \
@ -195,8 +184,6 @@ LANGTOOLS_MODULES := \
jdk.jshell \
#
CORBA_MODULES := java.corba
HOTSPOT_MODULES := \
jdk.aot \
jdk.hotspot.agent \
@ -395,7 +382,7 @@ FindTransitiveIndirectDepsForModules = \
# Upgradeable modules are those that are either defined as upgradeable or that
# require an upradeable module.
FindAllUpgradeableModules = \
$(sort $(filter-out $(MODULES_FILTER), $(UPGRADEABLE_MODULES) $(UPGRADEABLE_TOOL_MODULES)))
$(sort $(filter-out $(MODULES_FILTER), $(UPGRADEABLE_MODULES)))
################################################################################

View file

@ -1,34 +0,0 @@
#
# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code 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 General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
################################################################################
# Copy idl files to jdk/lib.
$(eval $(call SetupCopyFiles,COPY_IDL, \
SRC := $(TOPDIR)/src/java.corba/share/classes/com/sun/tools/corba/se/idl, \
DEST := $(SUPPORT_OUTPUTDIR)/modules_include/$(MODULE), \
FILES := $(TOPDIR)/src/java.corba/share/classes/com/sun/tools/corba/se/idl/orb.idl \
$(TOPDIR)/src/java.corba/share/classes/com/sun/tools/corba/se/idl/ir.idl))
TARGETS := $(COPY_IDL)

View file

@ -1,123 +0,0 @@
/*
* Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package build.tools.logutil;
import java.io.PrintWriter ;
import java.io.Writer ;
import java.io.OutputStream ;
import java.io.BufferedWriter ;
import java.io.OutputStreamWriter ;
import java.util.StringTokenizer ;
public class IndentingPrintWriter extends PrintWriter {
private int level = 0 ;
private int indentWidth = 4 ;
private String indentString = "" ;
public void printMsg( String msg, Object... data )
{
// System.out.println( "printMsg called with msg=" + msg + " data=" + data ) ;
StringTokenizer st = new StringTokenizer( msg, "@", true ) ;
StringBuffer result = new StringBuffer() ;
String token = null ;
int pos = 0;
while (st.hasMoreTokens()) {
token = st.nextToken() ;
if (token.equals("@")) {
if (pos < data.length) {
result.append( data[pos] );
++pos;
} else {
throw new Error( "List too short for message" ) ;
}
} else {
result.append( token ) ;
}
}
// System.out.println( "Printing result " + result + " to file" ) ;
print( result ) ;
println() ;
}
public IndentingPrintWriter (Writer out) {
super( out, true ) ;
// System.out.println( "Constructing a new IndentingPrintWriter with Writer " + out ) ;
}
public IndentingPrintWriter(Writer out, boolean autoFlush) {
super( out, autoFlush ) ;
// System.out.println( "Constructing a new IndentingPrintWriter with Writer " + out ) ;
}
public IndentingPrintWriter(OutputStream out) {
super(out, true);
// System.out.println( "Constructing a new IndentingPrintWriter with OutputStream " + out ) ;
}
public IndentingPrintWriter(OutputStream out, boolean autoFlush) {
super(new BufferedWriter(new OutputStreamWriter(out)), autoFlush);
// System.out.println( "Constructing a new IndentingPrintWriter with OutputStream " + out ) ;
}
public void setIndentWidth( int indentWidth )
{
this.indentWidth = indentWidth ;
updateIndentString() ;
}
public void indent()
{
level++ ;
updateIndentString() ;
}
public void undent()
{
if (level > 0) {
level-- ;
updateIndentString() ;
}
}
private void updateIndentString()
{
int size = level * indentWidth ;
StringBuffer sbuf = new StringBuffer( size ) ;
for (int ctr = 0; ctr<size; ctr++ )
sbuf.append( " " ) ;
indentString = sbuf.toString() ;
}
// overridden from PrintWriter
public void println()
{
super.println() ;
print( indentString ) ;
}
}

View file

@ -1,211 +0,0 @@
/*
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package build.tools.logutil;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Queue;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Input {
/**
* The name of the package this class will inhabit.
*/
private String packageName;
/**
* The name of the generated class.
*/
private String className;
/**
* The name of the group of exceptions handled by the class.
*/
private String groupName;
/**
* The group of exceptions.
*/
private Queue<InputException> exceptions;
/**
* Represents the current state of parsing the input.
*/
private enum State
{
OUTER,
IN_CLASS,
IN_EXCEPTION_LIST
};
/**
* Regular expression to match each code line.
*/
private static final Pattern EXCEPTION_INFO_REGEX =
Pattern.compile("(\\w+)\\s*(\\d+)\\s*(\\w+)");
/**
* Parses the specified file to create a new {@link Input}
* object.
*
* @param filename the file to parse.
* @throws FileNotFoundException if the file can't be found.
* @throws IOException if an I/O error occurs.
*/
public Input(final String filename)
throws FileNotFoundException, IOException {
BufferedReader r =
new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
State state = State.OUTER;
InputException current = null;
exceptions = new LinkedList<InputException>();
String line;
while ((line = r.readLine()) != null) {
// Skip ; comments
if (line.startsWith(";"))
continue;
int index = line.indexOf("(");
if (index == -1)
continue;
switch (state) {
case OUTER:
state = State.IN_CLASS;
String[] classInfo = line.substring(index).split(" ");
packageName = classInfo[0].substring(2, classInfo[0].length() - 1);
className = classInfo[1].substring(1, classInfo[1].length() - 1);
groupName = classInfo[2];
break;
case IN_CLASS:
state = State.IN_EXCEPTION_LIST;
break;
case IN_EXCEPTION_LIST:
boolean inQuote = false;
boolean inCode = false;
boolean end = false;
int start = index + 1;
Queue<String> lines = new LinkedList<String>();
for (int a = start; a < line.length(); ++a) {
if (line.charAt(a) == '(' && !inCode && !inQuote) {
if (current == null)
current =
new InputException(line.substring(start, a).trim());
start = a + 1;
inCode = true;
}
if (line.charAt(a) == '"')
inQuote = !inQuote;
if (line.charAt(a) == ')' && !inQuote) {
if (inCode) {
lines.offer(line.substring(start, a));
inCode = false;
} else
end = true;
}
if (!end && a == line.length() - 1)
line += r.readLine();
}
for (String l : lines) {
int stringStart = l.indexOf("\"") + 1;
int stringEnd = l.indexOf("\"", stringStart);
Matcher matcher = EXCEPTION_INFO_REGEX.matcher(l.substring(0, stringStart));
if (matcher.find())
current.add(new InputCode(matcher.group(1),
Integer.parseInt(matcher.group(2)),
matcher.group(3),
l.substring(stringStart, stringEnd)));
}
exceptions.offer(current);
current = null;
break;
}
}
}
/**
* Returns the name of this group of exceptions.
*
* @return the name of this group of exceptions.
*/
public String getGroupName()
{
return groupName;
}
/**
* Returns the name of the package this class will go in.
*
* @return the name of the package.
*/
public String getPackageName()
{
return packageName;
}
/**
* Returns the name of the generated class.
*
* @return the name of the class.
*/
public String getClassName()
{
return className;
}
/**
* Returns the exceptions contained in this class.
*
* @return the exceptions.
*/
public Queue<InputException> getExceptions() {
return exceptions;
}
/**
* Returns a textual representation of this input.
*
* @return a textual representation.
*/
public String toString() {
return getClass().getName() +
"[packageName=" + packageName +
",className=" + className +
",groupName=" + groupName +
",exceptions=" + exceptions +
"]";
}
}

View file

@ -1,116 +0,0 @@
/*
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package build.tools.logutil;
public class InputCode {
/**
* The name of this code.
*/
private final String name;
/**
* The code.
*/
private final int code;
/**
* The log level for this code.
*/
private final String logLevel;
/**
* The error message for this code.
*/
private final String message;
/**
* Creates a new error code with the specified name, code,
* log level and error message.
*
* @param name the name of the new code.
* @param code the code itself.
* @param logLevel the level of severity of this error.
* @param message the error message for this code.
*/
public InputCode(final String name, final int code,
final String logLevel, final String message) {
this.name = name;
this.code = code;
this.logLevel = logLevel;
this.message = message;
}
/**
* Returns the name of this code.
*
* @return the name of the code.
*/
public String getName() {
return name;
}
/**
* Returns the code.
*
* @return the code.
*/
public int getCode() {
return code;
}
/**
* Returns the severity of this code.
*
* @return the log level severity of the code.
*/
public String getLogLevel() {
return logLevel;
}
/**
* Returns the error message for this code.
*
* @return the error message for this code.
*/
public String getMessage() {
return message;
}
/**
* Returns a textual representation of this code.
*
* @return a textual representation.
*/
public String toString() {
return getClass().getName() +
"[name=" + name +
",code=" + code +
",logLevel=" + logLevel +
",message=" + message +
"]";
}
}

View file

@ -1,93 +0,0 @@
/*
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package build.tools.logutil;
import java.util.LinkedList;
import java.util.Queue;
public class InputException {
/**
* The name of this exception.
*/
private final String name;
/**
* The codes associated with this exception.
*/
private final Queue<InputCode> codes;
/**
* Constructs a new {@link InputException} with the
* specified name.
*
* @param name the name of the new exception;
*/
public InputException(final String name) {
this.name = name;
codes = new LinkedList<InputCode>();
}
/**
* Adds a new code to this exception.
*
* @param c the code to add.
*/
public void add(InputCode c)
{
codes.offer(c);
}
/**
* Returns the name of this exception.
*
* @return the exception's name.
*/
public String getName() {
return name;
}
/**
* Returns the codes associated with this exception.
*
* @return the exception's codes.
*/
public Queue<InputCode> getCodes() {
return codes;
}
/**
* Returns a textual representation of this exception.
*
* @return a textual representation.
*/
public String toString() {
return getClass().getName()
+ "[name=" + name
+ ",codes=" + codes
+ "]";
}
}

View file

@ -1,559 +0,0 @@
/*
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package build.tools.logutil;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.Formatter;
import java.util.List;
import java.util.Queue;
public class MC {
private static final String VERSION = "1.0";
private static final List<String> SUN_EXCEPTION_GROUPS = Arrays.asList(new String[]
{ "SUNBASE", "ORBUTIL", "ACTIVATION", "NAMING", "INTERCEPTORS", "POA", "IOR", "UTIL" });
private static final List<String> EXCEPTIONS = Arrays.asList(new String[]
{ "UNKNOWN", "BAD_PARAM", "NO_MEMORY", "IMP_LIMIT", "COMM_FAILURE", "INV_OBJREF", "NO_PERMISSION",
"INTERNAL", "MARSHAL", "INITIALIZE", "NO_IMPLEMENT", "BAD_TYPECODE", "BAD_OPERATION", "NO_RESOURCES",
"NO_RESPONSE", "PERSIST_STORE", "BAD_INV_ORDER", "TRANSIENT", "FREE_MEM", "INV_IDENT", "INV_FLAG",
"INTF_REPOS", "BAD_CONTEXT", "OBJ_ADAPTER", "DATA_CONVERSION", "OBJECT_NOT_EXIST", "TRANSACTION_REQUIRED",
"TRANSACTION_ROLLEDBACK", "INVALID_TRANSACTION", "INV_POLICY", "CODESET_INCOMPATIBLE", "REBIND",
"TIMEOUT", "TRANSACTION_UNAVAILABLE", "BAD_QOS", "INVALID_ACTIVITY", "ACTIVITY_COMPLETED",
"ACTIVITY_REQUIRED" });
/**
* Read the minor codes from the input file and
* write out a resource file.
*
* @param inFile the file to read the codes from.
* @param outDir the directory to write the resource file to.
* @throws FileNotFoundException if the input file can not be found.
* @throws IOException if an I/O error occurs.
*/
private void makeResource(String inFile, String outDir)
throws FileNotFoundException, IOException {
writeResource(outDir, new Input(inFile));
}
/**
* Create a new Java source file using the specified Scheme input file,
* and writing the result to the given output directory.
*
* @param inFile the file to read the data from.
* @param outDir the directory to write the Java class to.
* @throws FileNotFoundException if the input file can not be found.
* @throws IOException if an I/O error occurs.
*/
private void makeClass(String inFile, String outDir)
throws FileNotFoundException, IOException {
writeClass(inFile, outDir, new Input(inFile));
}
/**
* Writes out a Java source file using the data from the given
* {@link Input} object. The result is written to {@code outDir}.
* The name of the input file is just used in the header of the
* resulting source file.
*
* @param inFile the name of the file the data was read from.
* @param outDir the directory to write the Java class to.
* @param input the parsed input data.
* @throws FileNotFoundException if the output file can't be written.
*/
private void writeClass(String inFile, String outDir, Input input)
throws FileNotFoundException {
String packageName = input.getPackageName();
String className = input.getClassName();
String groupName = input.getGroupName();
Queue<InputException> exceptions = input.getExceptions();
FileOutputStream file = new FileOutputStream(outDir + File.separator + className + ".java");
IndentingPrintWriter pw = new IndentingPrintWriter(file);
writeClassHeader(inFile, groupName, pw);
pw.printMsg("package @ ;", packageName);
pw.println();
pw.println("import java.util.logging.Logger ;");
pw.println("import java.util.logging.Level ;");
pw.println();
pw.println("import org.omg.CORBA.OMGVMCID ;");
pw.println( "import com.sun.corba.se.impl.util.SUNVMCID ;");
pw.println( "import org.omg.CORBA.CompletionStatus ;");
pw.println( "import org.omg.CORBA.SystemException ;");
pw.println();
pw.println( "import com.sun.corba.se.spi.orb.ORB ;");
pw.println();
pw.println( "import com.sun.corba.se.spi.logging.LogWrapperFactory;");
pw.println();
pw.println( "import com.sun.corba.se.spi.logging.LogWrapperBase;");
pw.println();
writeImports(exceptions, pw);
pw.println();
pw.indent();
pw.printMsg("public class @ extends LogWrapperBase {", className);
pw.println();
pw.printMsg("public @( Logger logger )", className);
pw.indent();
pw.println( "{");
pw.undent();
pw.println( "super( logger ) ;");
pw.println( "}");
pw.println();
pw.flush();
writeFactoryMethod(className, groupName, pw);
writeExceptions(groupName, exceptions, className, pw);
pw.undent();
pw.println( );
pw.println( "}");
pw.flush();
pw.close();
}
/**
* Writes out the header of a Java source file.
*
* @param inFile the input file the file was generated from.
* @param groupName the group of exceptions the Java source file is for.
* @param pw the print writer used to write the output.
*/
private void writeClassHeader(String inFile, String groupName,
IndentingPrintWriter pw) {
if (groupName.equals("OMG"))
pw.println("// Log wrapper class for standard exceptions");
else
pw.printMsg("// Log wrapper class for Sun private system exceptions in group @",
groupName);
pw.println("//");
pw.printMsg("// Generated by MC.java version @, DO NOT EDIT BY HAND!", VERSION);
pw.printMsg("// Generated from input file @ on @", inFile, new Date());
pw.println();
}
/**
* Write out the import list for the exceptions.
*
* @param groups the exceptions that were parsed.
* @param pw the {@link IndentingPrintWriter} for writing to the file.
*/
private void writeImports(Queue<InputException> exceptions,
IndentingPrintWriter pw) {
if (exceptions == null)
return;
for (InputException e : exceptions)
pw.println("import org.omg.CORBA." + e.getName() + " ;");
}
/**
* Write out the factory method for this group of exceptions.
*
* @param className the name of the generated class.
* @param groupName the name of this group of exceptions.
* @param pw the {@link IndentingPrintWriter} for writing to the file.
*/
private void writeFactoryMethod(String className, String groupName,
IndentingPrintWriter pw) {
pw.indent();
pw.println( "private static LogWrapperFactory factory = new LogWrapperFactory() {");
pw.println( "public LogWrapperBase create( Logger logger )" );
pw.indent();
pw.println( "{");
pw.undent();
pw.printMsg("return new @( logger ) ;", className);
pw.undent();
pw.println( "}" );
pw.println( "} ;" );
pw.println();
pw.printMsg("public static @ get( ORB orb, String logDomain )", className);
pw.indent();
pw.println( "{");
pw.indent();
pw.printMsg( "@ wrapper = ", className);
pw.indent();
pw.printMsg( "(@) orb.getLogWrapper( logDomain, ", className);
pw.undent();
pw.undent();
pw.printMsg( "\"@\", factory ) ;", groupName);
pw.undent();
pw.println( "return wrapper ;" );
pw.println( "} " );
pw.println();
pw.printMsg( "public static @ get( String logDomain )", className);
pw.indent();
pw.println( "{");
pw.indent();
pw.printMsg( "@ wrapper = ", className);
pw.indent();
pw.printMsg( "(@) ORB.staticGetLogWrapper( logDomain, ", className);
pw.undent();
pw.undent();
pw.printMsg( "\"@\", factory ) ;", groupName);
pw.undent();
pw.println( "return wrapper ;" );
pw.println( "} " );
pw.println();
}
/**
* Writes out the exceptions themselves.
*
* @param groupName the name of this group of exceptions.
* @param exceptions the exceptions to write out.
* @param className the name of the generated class.
* @param pw the {@link IndentingPrintWriter} for writing to the file.
*/
private void writeExceptions(String groupName, Queue<InputException> exceptions,
String className, IndentingPrintWriter pw) {
for (InputException e : exceptions) {
pw.println("///////////////////////////////////////////////////////////");
pw.printMsg("// @", e.getName());
pw.println("///////////////////////////////////////////////////////////");
pw.println();
for (InputCode c : e.getCodes())
writeMethods(groupName, e.getName(), c.getName(), c.getCode(),
c.getLogLevel(), className, StringUtil.countArgs(c.getMessage()), pw);
pw.flush();
}
}
/**
* Writes out the methods for a particular error.
*
* @param groupName the name of this group of exceptions.
* @param exceptionName the name of this particular exception.
* @param errorName the name of this particular error.
* @param code the minor code for this particular error.
* @param ident the name of the error in mixed-case identifier form.
* @param level the level at which to place log messages.
* @param className the name of the class for this group of exceptions.
* @param numParams the number of parameters the detail message takes.
* @param pw the print writer for writing to the file.
*/
private void writeMethods(String groupName, String exceptionName, String errorName,
int code, String level, String className, int numParams,
IndentingPrintWriter pw) {
String ident = StringUtil.toMixedCase(errorName);
pw.printMsg("public static final int @ = @ ;", errorName, getBase(groupName, code));
pw.println();
pw.flush();
writeMethodStatusCause(groupName, exceptionName, errorName, ident, level,
numParams, className, pw);
pw.println();
pw.flush();
writeMethodStatus(exceptionName, ident, numParams, pw);
pw.println();
pw.flush();
writeMethodCause(exceptionName, ident, numParams, pw);
pw.println();
pw.flush();
writeMethodNoArgs(exceptionName, ident, numParams, pw);
pw.println();
pw.flush();
}
/**
* Writes out a method for an error that takes a
* {@link org.omg.CORBA.CompletionStatus} and a cause.
*
* @param groupName the name of this group of exceptions.
* @param exceptionName the name of this particular exception.
* @param errorName the name of this particular error.
* @param ident the name of the error in mixed-case identifier form.
* @param logLevel the level at which to place log messages.
* @param numParams the number of parameters the detail message takes.
* @param className the name of the class for this group of exceptions.
* @param pw the print writer for writing to the file.
*/
private void writeMethodStatusCause(String groupName, String exceptionName,
String errorName, String ident,
String logLevel, int numParams,
String className, IndentingPrintWriter pw) {
pw.indent();
pw.printMsg( "public @ @( CompletionStatus cs, Throwable t@) {", exceptionName,
ident, makeDeclArgs(true, numParams));
pw.printMsg( "@ exc = new @( @, cs ) ;", exceptionName, exceptionName, errorName);
pw.indent();
pw.println( "if (t != null)" );
pw.undent();
pw.println( "exc.initCause( t ) ;" );
pw.println();
pw.indent();
pw.printMsg( "if (logger.isLoggable( Level.@ )) {", logLevel);
if (numParams > 0) {
pw.printMsg( "Object[] parameters = new Object[@] ;", numParams);
for (int a = 0; a < numParams; ++a)
pw.printMsg("parameters[@] = arg@ ;", a, a);
} else
pw.println( "Object[] parameters = null ;");
pw.indent();
pw.printMsg( "doLog( Level.@, \"@.@\",", logLevel, groupName, ident);
pw.undent();
pw.undent();
pw.printMsg( "parameters, @.class, exc ) ;", className);
pw.println( "}");
pw.println();
pw.undent();
pw.println( "return exc ;");
pw.println( "}");
}
/**
* Writes out a method for an error that takes a
* {@link org.omg.CORBA.CompletionStatus}.
*
* @param exceptionName the name of this particular exception.
* @param ident the name of the error in mixed-case identifier form.
* @param numParams the number of parameters the detail message takes.
* @param pw the print writer for writing to the file.
*/
private void writeMethodStatus(String exceptionName, String ident,
int numParams, IndentingPrintWriter pw) {
pw.indent();
pw.printMsg("public @ @( CompletionStatus cs@) {", exceptionName,
ident, makeDeclArgs(true, numParams));
pw.undent();
pw.printMsg("return @( cs, null@ ) ;", ident, makeCallArgs(true, numParams));
pw.println("}");
}
/**
* Writes out a method for an error that takes a cause.
*
* @param exceptionName the name of this particular exception.
* @param ident the name of the error in mixed-case identifier form.
* @param numParams the number of parameters the detail message takes.
* @param pw the print writer for writing to the file.
*/
private void writeMethodCause(String exceptionName, String ident,
int numParams, IndentingPrintWriter pw) {
pw.indent();
pw.printMsg("public @ @( Throwable t@) {", exceptionName, ident,
makeDeclArgs(true, numParams));
pw.undent();
pw.printMsg("return @( CompletionStatus.COMPLETED_NO, t@ ) ;", ident,
makeCallArgs(true, numParams));
pw.println("}");
}
/**
* Writes out a method for an error that takes no arguments.
*
* @param exceptionName the name of this particular exception.
* @param ident the name of the error in mixed-case identifier form.
* @param numParams the number of parameters the detail message takes.
* @param pw the print writer for writing to the file.
*/
private void writeMethodNoArgs(String exceptionName, String ident,
int numParams, IndentingPrintWriter pw) {
pw.indent();
pw.printMsg("public @ @( @) {", exceptionName, ident,
makeDeclArgs(false, numParams));
pw.undent();
pw.printMsg("return @( CompletionStatus.COMPLETED_NO, null@ ) ;",
ident, makeCallArgs(true, numParams));
pw.println("}");
}
/**
* Returns a list of comma-separated arguments with type declarations.
*
* @param leadingComma true if the list should start with a comma.
* @param numArgs the number of arguments to generate.
* @return the generated string.
*/
private String makeDeclArgs(boolean leadingComma, int numArgs) {
return makeArgString("Object arg", leadingComma, numArgs);
}
/**
* Returns a list of comma-separated arguments without type declarations.
*
* @param leadingComma true if the list should start with a comma.
* @param numArgs the number of arguments to generate.
* @return the generated string.
*/
private String makeCallArgs(boolean leadingComma, int numArgs) {
return makeArgString("arg", leadingComma, numArgs);
}
/**
* Returns a list of comma-separated arguments.
*
* @param prefixString the string with which to prefix each argument.
* @param leadingComma true if the list should start with a comma.
* @param numArgs the number of arguments to generate.
* @return the generated string.
*/
private String makeArgString(String prefixString, boolean leadingComma,
int numArgs) {
if (numArgs == 0)
return " ";
if (numArgs == 1) {
if (leadingComma)
return ", " + prefixString + (numArgs - 1);
else
return " " + prefixString + (numArgs - 1);
}
return makeArgString(prefixString, leadingComma, numArgs - 1) +
", " + prefixString + (numArgs - 1);
}
/**
* Returns the {@link String} containing the calculation of the
* error code.
*
* @param groupName the group of exception to which the code belongs.
* @param code the minor code number representing the exception within the group.
* @return the unique error code.
*/
private String getBase(String groupName, int code) {
if (groupName.equals("OMG"))
return "OMGVMCID.value + " + code;
else
return "SUNVMCID.value + " + (code + getSunBaseNumber(groupName));
}
/**
* Returns the base number for Sun-specific exceptions.
*
* @return the base number.
*/
private int getSunBaseNumber(String groupName) {
return 200 * SUN_EXCEPTION_GROUPS.indexOf(groupName);
}
/**
* Writes out a resource file using the data from the given
* {@link Input} object. The result is written to {@code outDir}.
*
* @param outDir the directory to write the Java class to.
* @param input the parsed input data.
* @throws FileNotFoundException if the output file can't be written.
*/
private void writeResource(String outDir, Input input)
throws FileNotFoundException {
FileOutputStream file = new FileOutputStream(outDir + File.separator +
input.getClassName() + ".resource");
IndentingPrintWriter pw = new IndentingPrintWriter(file);
String groupName = input.getGroupName();
for (InputException e : input.getExceptions()) {
String exName = e.getName();
for (InputCode c : e.getCodes()) {
String ident = StringUtil.toMixedCase(c.getName());
pw.printMsg("@.@=\"@: (@) @\"", groupName, ident,
getMessageID(groupName, exName, c.getCode()), exName, c.getMessage());
}
pw.flush();
}
pw.close();
}
/**
* Returns the message ID corresponding to the given group name,
* exception name and error code.
*
* @param groupName the name of the group of exceptions.
* @param exception the name of the particular exception.
* @param code an error code from the given exception.
* @return the message ID.
*/
private String getMessageID(String groupName, String exceptionName, int code) {
if (groupName.equals("OMG"))
return getStandardMessageID(exceptionName, code);
else
return getSunMessageID(groupName, exceptionName, code);
}
/**
* Returns the standard (OMG) message ID corresponding to the given
* exception name and error code.
*
* @param exceptionName the name of the particular exception.
* @param code an error code from the given exception.
* @return the message ID.
*/
private String getStandardMessageID(String exceptionName, int code) {
return new Formatter().format("IOP%s0%04d", getExceptionID(exceptionName),
code).toString();
}
/**
* Returns the Sun message ID corresponding to the given group name,
* exception name and error code.
*
* @param groupName the name of the group of exceptions.
* @param exceptionName the name of the particular exception.
* @param code an error code from the given exception.
* @return the message ID.
*/
private String getSunMessageID(String groupName, String exceptionName, int code) {
return new Formatter().format("IOP%s1%04d", getExceptionID(exceptionName),
getSunBaseNumber(groupName) + code).toString();
}
/**
* Returns the exception ID corresponding to the given exception name.
*
* @param exceptionName the name of the particular exception.
* @return the message ID.
*/
private String getExceptionID(String exceptionName) {
return new Formatter().format("%03d", EXCEPTIONS.indexOf(exceptionName)).toString();
}
/**
* Entry point for running the generator from the command
* line. Users can specify either "make-class" or "make-resource"
* as the first argument to generate the specified type of file.
*
* @param args the command-line arguments.
* @throws FileNotFoundException if the input file can not be found.
* @throws IOException if an I/O error occurs.
*/
public static void main(String[] args)
throws FileNotFoundException, IOException
{
if (args.length < 3)
{
System.err.println("(make-class|make-resource) <input file> <output dir>");
System.exit(-1);
}
if (args[0].equals("make-class"))
new MC().makeClass(args[1], args[2]);
else if (args[0].equals("make-resource"))
new MC().makeResource(args[1], args[2]);
else
System.err.println("Invalid command: " + args[0]);
}
}

View file

@ -1,62 +0,0 @@
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package build.tools.logutil;
public abstract class StringUtil {
/** Take a string containing underscores, and return a string
* with the underscore removed, and all characters exception in lower
* case except the characters after the underscores.
*/
public static String toMixedCase( String str )
{
StringBuffer sbuf = new StringBuffer( str.length() ) ;
boolean uppercaseNext = false ;
for (int ctr=0; ctr<str.length(); ctr++) {
char ch = str.charAt( ctr ) ;
if (ch == '_') {
uppercaseNext = true ;
} else if (uppercaseNext) {
sbuf.append( Character.toUpperCase( ch ) ) ;
uppercaseNext = false ;
} else {
sbuf.append( Character.toLowerCase( ch ) ) ;
}
}
return sbuf.toString() ;
}
public static int countArgs( String str )
{
int result = 0 ;
for( int ctr = 0; ctr<str.length(); ctr++ )
if (str.charAt(ctr) == '{')
result++ ;
return result ;
}
}

View file

@ -1,242 +0,0 @@
#
# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code 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 General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
default: all
include $(SPEC)
include MakeBase.gmk
include JavaCompilation.gmk
include IdlCompilation.gmk
include SetupJavaCompilers.gmk
################################################################################
$(eval $(call SetupJavaCompilation,BUILD_TOOLS_CORBA, \
SETUP := GENERATE_OLDBYTECODE, \
SRC := $(TOPDIR)/make/corba/src/classes, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/corba_tools_classes))
TOOL_LOGUTIL_CMD := $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/corba_tools_classes \
build.tools.logutil.MC
$(eval $(call SetupJavaCompilation,BUILD_IDLJ, \
SETUP := GENERATE_OLDBYTECODE, \
SRC := $(TOPDIR)/src/java.corba/share/classes, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/idlj_classes, \
COPY := .prp, \
INCLUDES := com/sun/tools/corba/se/idl, \
EXCLUDE_FILES := ResourceBundleUtil.java module-info.java))
# Force the language to english for predictable source code generation.
TOOL_IDLJ_CMD := $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/idlj_classes \
-Duser.language=en com.sun.tools.corba.se.idl.toJavaPortable.Compile
################################################################################
EXCEPTION_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.corba/com/sun/corba/se/impl/logging
LOGWRAPPER_DIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.corba/_logwrappers
# Generate LogWrapper classes
$(EXCEPTION_DIR)/%SystemException.java: \
$(TOPDIR)/src/java.corba/share/classes/com/sun/corba/se/spi/logging/data/%.mc \
$(BUILD_TOOLS_CORBA)
$(call LogInfo, Generating class file from $*.mc)
$(call MakeDir, $(@D))
$(RM) -f $(@D)/_the_wrappers.d
$(TOOL_LOGUTIL_CMD) make-class $< $(@D)
# Generate LogWrapper properties file by concatening resource files
$(EXCEPTION_DIR)/LogStrings.properties: \
$(LOGWRAPPER_DIR)/ActivationSystemException.resource \
$(LOGWRAPPER_DIR)/IORSystemException.resource \
$(LOGWRAPPER_DIR)/InterceptorsSystemException.resource \
$(LOGWRAPPER_DIR)/NamingSystemException.resource \
$(LOGWRAPPER_DIR)/OMGSystemException.resource \
$(LOGWRAPPER_DIR)/ORBUtilSystemException.resource \
$(LOGWRAPPER_DIR)/POASystemException.resource \
$(LOGWRAPPER_DIR)/UtilSystemException.resource
$(call LogInfo, Concatenating 8 resource files into $(@F))
$(call MakeDir, $(@D))
$(CAT) $^ > $@
# The resources files are generated from lisp-like .mc files.
$(LOGWRAPPER_DIR)/%SystemException.resource: \
$(TOPDIR)/src/java.corba/share/classes/com/sun/corba/se/spi/logging/data/%.mc \
$(BUILD_TOOLS_CORBA)
$(call LogInfo, Generating resource file from $*.mc)
$(call MakeDir, $(@D))
$(RM) -f $(@D)/_the_wrappers.d
$(TOOL_LOGUTIL_CMD) make-resource $< $(@D)
LOGWRAPPER_TARGETS := \
$(EXCEPTION_DIR)/ActivationSystemException.java \
$(EXCEPTION_DIR)/IORSystemException.java \
$(EXCEPTION_DIR)/InterceptorsSystemException.java \
$(EXCEPTION_DIR)/NamingSystemException.java \
$(EXCEPTION_DIR)/OMGSystemException.java \
$(EXCEPTION_DIR)/ORBUtilSystemException.java \
$(EXCEPTION_DIR)/POASystemException.java \
$(EXCEPTION_DIR)/UtilSystemException.java \
$(EXCEPTION_DIR)/LogStrings.properties
################################################################################
# Build the IDLs.
IDL_DELETES := \
org/omg/DynamicAny/*POA* \
org/omg/DynamicAny/*Holder* \
org/omg/DynamicAny/DynValueBoxHelper.java \
org/omg/DynamicAny/DynValueCommonHelper.java \
org/omg/DynamicAny/_DynValueCommonStub.java \
org/omg/DynamicAny/_DynValueBoxStub.java \
org/omg/DynamicAny/DynAnyPackage/TypeMismatchHolder.java \
org/omg/DynamicAny/DynAnyPackage/InvalidValueHolder.java \
org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHolder.java \
org/omg/IOP/BI_DIR_IIOP.java \
org/omg/IOP/ChainBypassCheck.java \
org/omg/IOP/ChainBypassInfo.java \
org/omg/IOP/FORWARDED_IDENTITY.java \
org/omg/IOP/INVOCATION_POLICIES.java \
org/omg/IOP/LogicalThreadId.java \
org/omg/IOP/SendingContextRunTime.java \
org/omg/IOP/UnknownExceptionInfo.java \
org/omg/IOP/TaggedComponentSeqHolder.java \
org/omg/PortableServer/CurrentPackage/NoContextHolder.java \
org/omg/PortableServer/ForwardRequestHolder.java \
org/omg/PortableServer/IdAssignmentPolicyValueHelper.java \
org/omg/PortableServer/IdAssignmentPolicyValueHolder.java \
org/omg/PortableServer/IdUniquenessPolicyValueHelper.java \
org/omg/PortableServer/IdUniquenessPolicyValueHolder.java \
org/omg/PortableServer/ImplicitActivationPolicyValueHelper.java \
org/omg/PortableServer/ImplicitActivationPolicyValueHolder.java \
org/omg/PortableServer/LifespanPolicyValueHelper.java \
org/omg/PortableServer/LifespanPolicyValueHolder.java \
org/omg/PortableServer/ServantRetentionPolicyValueHelper.java \
org/omg/PortableServer/ServantRetentionPolicyValueHolder.java \
org/omg/PortableServer/ObjectIdHelper.java \
org/omg/PortableServer/ObjectIdHolder.java \
org/omg/PortableServer/POAListHelper.java \
org/omg/PortableServer/POAListHolder.java \
org/omg/PortableServer/POAManagerPackage/AdapterInactiveHolder.java \
org/omg/PortableServer/POAManagerPackage/StateHelper.java \
org/omg/PortableServer/POAManagerPackage/StateHolder.java \
org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHolder.java \
org/omg/PortableServer/POAPackage/AdapterNonExistentHolder.java \
org/omg/PortableServer/POAPackage/InvalidPolicyHolder.java \
org/omg/PortableServer/POAPackage/NoServantHolder.java \
org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHolder.java \
org/omg/PortableServer/POAPackage/ObjectNotActiveHolder.java \
org/omg/PortableServer/POAPackage/ServantAlreadyActiveHolder.java \
org/omg/PortableServer/POAPackage/ServantNotActiveHolder.java \
org/omg/PortableServer/POAPackage/WrongAdapterHolder.java \
org/omg/PortableServer/POAPackage/WrongPolicyHolder.java \
org/omg/PortableServer/RequestProcessingPolicyValueHelper.java \
org/omg/PortableServer/RequestProcessingPolicyValueHolder.java \
org/omg/PortableServer/ServantActivatorHolder.java \
org/omg/PortableServer/ServantLocatorHolder.java \
org/omg/PortableServer/ThreadPolicyValueHelper.java \
org/omg/PortableServer/ThreadPolicyValueHolder.java \
org/omg/PortableInterceptor/ClientRequestInfoHelper.java \
org/omg/PortableInterceptor/ClientRequestInterceptorHelper.java \
org/omg/PortableInterceptor/IORInfoHelper.java \
org/omg/PortableInterceptor/IORInterceptorHelper.java \
org/omg/PortableInterceptor/InterceptorHelper.java \
org/omg/PortableInterceptor/ORBInitInfoHelper.java \
org/omg/PortableInterceptor/ORBInitializerHelper.java \
org/omg/PortableInterceptor/PolicyFactoryHelper.java \
org/omg/PortableInterceptor/ReplyStatusHelper.java \
org/omg/PortableInterceptor/RequestInfoHelper.java \
org/omg/PortableInterceptor/ServerRequestInfoHelper.java \
org/omg/PortableInterceptor/ServerRequestInterceptorHelper.java \
org/omg/PortableInterceptor/SlotIdHelper.java \
org/omg/PortableInterceptor/ClientRequestInfoHolder.java \
org/omg/PortableInterceptor/ClientRequestInterceptorHolder.java \
org/omg/PortableInterceptor/CurrentHolder.java \
org/omg/PortableInterceptor/ForwardRequestHolder.java \
org/omg/PortableInterceptor/IORInfoHolder.java \
org/omg/PortableInterceptor/IORInterceptorHolder.java \
org/omg/PortableInterceptor/InterceptorHolder.java \
org/omg/PortableInterceptor/InvalidSlotHolder.java \
org/omg/PortableInterceptor/ORBInitInfoHolder.java \
org/omg/PortableInterceptor/ORBInitializerHolder.java \
org/omg/PortableInterceptor/PolicyFactoryHolder.java \
org/omg/PortableInterceptor/RequestInfoHolder.java \
org/omg/PortableInterceptor/ServerRequestInfoHolder.java \
org/omg/PortableInterceptor/ServerRequestInterceptorHolder.java \
org/omg/PortableInterceptor/TaggedComponentSeqHolder.java \
org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHolder.java \
org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHolder.java \
org/omg/IOP/CodecPackage/FormatMismatchHolder.java \
org/omg/IOP/CodecPackage/InvalidTypeForEncodingHolder.java \
org/omg/IOP/CodecPackage/TypeMismatchHolder.java \
org/omg/IOP/CodecHelper.java \
org/omg/IOP/EncodingFormatHelper.java \
org/omg/IOP/EncodingHelper.java \
org/omg/IOP/CodecFactoryPackage/UnknownEncodingHolder.java \
org/omg/IOP/CodecFactoryHolder.java \
org/omg/IOP/CodecHolder.java \
org/omg/IOP/EncodingHolder.java \
org/omg/IOP/TaggedComponentSeqHelper.java \
org/omg/Dynamic/ContextListHelper.java \
org/omg/Dynamic/ExceptionListHelper.java \
org/omg/Dynamic/ParameterHolder.java \
org/omg/Dynamic/ParameterListHolder.java \
org/omg/Dynamic/ExceptionListHolder.java \
org/omg/Dynamic/ParameterHelper.java \
org/omg/Dynamic/ParameterListHelper.java \
org/omg/Dynamic/RequestContextHelper.java \
org/omg/CORBA/OctetSeqHelper.java \
org/omg/CORBA/OctetSeqHolder.java \
org/omg/CORBA/PolicyError.java \
org/omg/CORBA/RepositoryIdHelper.java \
#
$(eval $(call SetupIdlCompilation,BUILD_IDLS, \
IDLJ := $(TOOL_IDLJ_CMD), \
SRC := $(TOPDIR)/src/java.corba/share/classes, \
BIN := $(SUPPORT_OUTPUTDIR)/gensrc/java.corba, \
EXCLUDES := com/sun/tools/corba/se/idl/% \
org/omg/CORBA/% \
com/sun/corba/se/GiopIDL/% \
org/omg/PortableServer/corba.idl, \
INCLUDES := %, \
OLDIMPLBASES := com/sun/corba/se/PortableActivationIDL/activation.idl \
com/sun/corba/se/spi/activation/activation.idl, \
DELETES := $(IDL_DELETES)))
$(BUILD_IDLS): $(BUILD_IDLJ)
################################################################################
# zh_HK is just a copy of zh_TW
$(SUPPORT_OUTPUTDIR)/gensrc/java.corba/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_HK.properties: \
$(TOPDIR)/src/java.corba/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_TW.properties
$(install-file)
################################################################################
all: $(BUILD_IDLS) $(LOGWRAPPER_TARGETS) \
$(SUPPORT_OUTPUTDIR)/gensrc/java.corba/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_HK.properties

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -144,8 +144,6 @@ public class GenGraphs {
ranks.add(Set.of("java.sql"));
ranks.add(Set.of("java.compiler", "java.instrument"));
ranks.add(Set.of("java.desktop", "java.management"));
ranks.add(Set.of("java.corba", "java.xml.ws"));
ranks.add(Set.of("java.xml.bind", "java.xml.ws.annotation"));
this.attrs = attrs;
}

View file

@ -1,11 +1,10 @@
<html>
<head>
<title>JCP Technologies in JDK 9</title>
<title>JCP Technologies in JDK 11</title>
<style type="text/css">
table { border: 1px solid black; border-collapse: collapse; }
tr.se-base { background-color: yellow; }
tr.se-misc { background-color: bisque; }
tr.se-ee { background-color: sandybrown; }
tr.se-ext { background-color: pink; }
tr.non-se { background-color: lightsteelblue; }
td { font-family: monospace; padding: 5px; border: 1px solid; }
@ -13,19 +12,18 @@ td.agg { background-color: lightgray; }
</style>
</head>
<h1>JCP Technologies in JDK 9</h1>
<h1>JCP Technologies in JDK 11</h1>
<p><em>Last updated 2017-06-08</em></p>
<p><em>Last updated 2018-02-07</em></p>
<p><a href="module-summary.html">JDK 9 Module Summary</a> | Technologies in the <a href="https://docs.oracle.com/javase/8/docs/">Java SE 8 Documentation</a></p>
<p><a href="module-summary.html">JDK 11 Module Summary</a> | Technologies in the <a href="https://docs.oracle.com/javase/9/docs/">Java SE 9 Documentation</a></p>
<table>
<tr><th>Legend</th></tr>
<tr class="se-base"><td><a href="https://jcp.org/en/jsr/platform?listBy=2&listByType=platform">JCP technology in the Java SE Platform only -- in java.base</a></td></tr>
<tr class="se-misc"><td><a href="https://jcp.org/en/jsr/platform?listBy=2&listByType=platform">JCP technology in the Java SE Platform only -- not in java.base</a></td></tr>
<tr class="se-ee"><td><a href="https://jcp.org/en/jsr/platform?listBy=3&listByType=platform">JCP technology in the Java SE Platform derived from the Java EE Platform</a></a></td></tr>
<tr class="se-ext"><td><a href="http://docs.oracle.com/javase/8/docs/technotes/guides/standards/#endorsed-standards-apis">JCP technology in the Java SE Platform derived from non-JCP standards</a></a></td></tr>
<tr class="non-se"><td>JCP technology in neither the Java SE or EE Platforms</td></tr>
<tr class="non-se"><td>JCP technology not included in the Java SE Platform</td></tr>
</table>
<br/>
@ -50,7 +48,7 @@ td.agg { background-color: lightgray; }
<td>boot</td>
<td>No</td>
<td></td>
<td class="agg" rowspan=37><a href="module-summary.html#java.se"/>java.se</a></td>
<td class="agg" rowspan=38><a href="module-summary.html#java.se"/>java.se</a></td>
</tr>
<tr class="se-misc">
@ -403,6 +401,15 @@ td.agg { background-color: lightgray; }
<td>No</td>
<td></td>
</tr>
<tr class="se-misc">
<td><a href="https://jcp.org/en/jsr/detail?id=907">907</a></td>
<td>JTA (XA)</td>
<td>Original JSR</td>
<td><a href="module-summary.html#java.sql">java.sql</a></td>
<td>plat</td>
<td>No</td>
<td>Formerly a <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/standards/#standalone-technologies">Standalone Technology</a> (unlisted)</td>
</tr>
<tr class="se-ext">
<td>(W3C)</td>
@ -414,102 +421,6 @@ td.agg { background-color: lightgray; }
<td>Formerly an <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/standards/#endorsed-standards-apis">Endorsed Standard</a></td>
</tr>
<tr class="se-ext">
<td>(OMG)</td>
<td>RMI-IIOP, IDL</td>
<td>UJSR for Java SE</td>
<td><a href="module-summary.html#java.corba"/>java.corba</a></td>
<td>plat</td>
<td>Yes</td>
<td>Formerly an <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/standards/#endorsed-standards-apis">Endorsed Standard</a></td>
<td class="agg" rowspan=7><a href="module-summary.html#java.se.ee"/>java.se.ee</a></td>
</tr>
<tr class="se-ee">
<td><a href="https://jcp.org/en/jsr/detail?id=67">67</a></td>
<td>SAAJ</td>
<td>Original JSR</td>
<td><a href="module-summary.html#java.xml.ws">java.xml.ws</a></td>
<td>plat</td>
<td>Yes</td>
<td>Formerly a <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/standards/#standalone-technologies">Standalone Technology</a> (f.k.a. JAXM)</td>
</tr>
<tr class="se-ee">
<td><a href="https://jcp.org/en/jsr/detail?id=181">181</a></td>
<td>Web Services Metadata</td>
<td>Original JSR</td>
<td><a href="module-summary.html#java.xml.ws">java.xml.ws</a></td>
<td>plat</td>
<td>Yes</td>
<td>Formerly a <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/standards/#standalone-technologies">Standalone Technology</a> (unlisted)</td>
</tr>
<tr class="se-ee">
<td><a href="https://jcp.org/en/jsr/detail?id=222">222</a></td>
<td>JAXB</td>
<td>Original JSR</td>
<td><a href="module-summary.html#java.xml.bind">java.xml.bind</a></td>
<td>plat</td>
<td>Yes</td>
<td>Formerly a <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/standards/#standalone-technologies">Standalone Technology</a></td>
</tr>
<tr class="se-ee">
<td><a href="https://jcp.org/en/jsr/detail?id=224">224</a></td>
<td>JAXWS</td>
<td>Original JSR</td>
<td><a href="module-summary.html#java.xml.ws">java.xml.ws</a></td>
<td>plat</td>
<td>Yes</td>
<td>Formerly a <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/standards/#standalone-technologies">Standalone Technology</a></td>
</tr>
<!-- The Java SE Platform incorporates a smaller version of the javax.annotation package than the Java EE Platform. -->
<tr class="se-ee">
<td><a href="https://jcp.org/en/jsr/detail?id=250">250</a></td>
<td>Common Annotations</td>
<td>Original JSR</td>
<td><a href="module-summary.html#java.xml.ws.annotation">java.xml.ws.annotation</a></td>
<td>plat</td>
<td>Yes</td>
<td>Formerly a <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/standards/#standalone-technologies">Standalone Technology</a> (unlisted)</td>
</tr>
<!-- The Java SE Platform incorporates a smaller version of the javax.transaction package than the Java EE Platform. -->
<tr class="se-ee">
<td><a href="https://jcp.org/en/jsr/detail?id=907">907</a></td>
<td>JTA (non-XA)</td>
<td>Original JSR</td>
<td><a href="module-summary.html#java.transaction">java.transaction</a></td>
<td>plat</td>
<td>Yes</td>
<td>Formerly a <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/standards/#standalone-technologies">Standalone Technology</a> (unlisted)</td>
</tr>
<!-- The Java SE Platform incorporates the same version of the javax.transaction.xa package as the Java EE Platform. -->
<tr class="se-ee">
<td><a href="https://jcp.org/en/jsr/detail?id=907">907</a></td>
<td>JTA (XA)</td>
<td>Original JSR</td>
<td><a href="module-summary.html#java.sql"/>java.sql</a></td>
<td>plat</td>
<td>No</td>
<td>Formerly a <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/standards/#standalone-technologies">Standalone Technology</a> (unlisted)</td>
<td class="agg"><a href="module-summary.html#java.se"/>java.se</a></td>
</tr>
<tr class="se-misc">
<td><a href="https://jcp.org/en/jsr/detail?id=925">925</a></td>
<td>JAF</td>
<td>Original JSR</td>
<td><a href="module-summary.html#java.activation">java.activation</a></a></td>
<td>plat</td>
<td>Yes</td>
<td>Formerly a <a href="http://docs.oracle.com/javase/8/docs/technotes/guides/standards/#standalone-technologies">Standalone Technology</a> (unlisted)</td>
<td class="agg"><a href="module-summary.html#java.se.ee"/>java.se.ee</a></td>
</tr>
<tr class="non-se">
<td><a href="https://jcp.org/en/jsr/detail?id=56">56</a></td>
<td>JNLP</td>

View file

@ -1,50 +0,0 @@
#
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code 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 General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
include LauncherCommon.gmk
$(eval $(call SetupBuildLauncher, idlj, \
MAIN_CLASS := com.sun.tools.corba.se.idl.toJavaPortable.Compile, \
))
$(eval $(call SetupBuildLauncher, orbd, \
MAIN_CLASS := com.sun.corba.se.impl.activation.ORBD, \
JAVA_ARGS := \
-Dcom.sun.CORBA.activation.DbDir=./orb.db \
-Dcom.sun.CORBA.activation.Port=1049 \
-Dcom.sun.CORBA.POA.ORBServerId=1, \
))
$(eval $(call SetupBuildLauncher, servertool, \
MAIN_CLASS := com.sun.corba.se.impl.activation.ServerTool, \
))
$(eval $(call SetupBuildLauncher, tnameserv, \
MAIN_CLASS := com.sun.corba.se.impl.naming.cosnaming.TransientNameServer, \
JAVA_ARGS := \
-Dcom.sun.CORBA.activation.DbDir=./orb.db \
-Djava.util.logging.LoggingPermission=contol \
-Dcom.sun.CORBA.POA.ORBServerId=1, \
))

View file

@ -1,34 +0,0 @@
#
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code 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 General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
include LauncherCommon.gmk
$(eval $(call SetupBuildLauncher, schemagen, \
MAIN_CLASS := com.sun.tools.internal.jxc.SchemaGenerator, \
))
$(eval $(call SetupBuildLauncher, xjc, \
MAIN_CLASS := com.sun.tools.internal.xjc.Driver, \
))

View file

@ -1,34 +0,0 @@
#
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code 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 General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
include LauncherCommon.gmk
$(eval $(call SetupBuildLauncher, wsgen, \
MAIN_CLASS := com.sun.tools.internal.ws.WsGen, \
))
$(eval $(call SetupBuildLauncher, wsimport, \
MAIN_CLASS := com.sun.tools.internal.ws.WsImport, \
))

View file

@ -1,567 +0,0 @@
'\" t
.\" Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
.\"
.\" This code is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License version 2 only, as
.\" published by the Free Software Foundation.
.\"
.\" This code 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 General Public License
.\" version 2 for more details (a copy is included in the LICENSE file that
.\" accompanied this code).
.\"
.\" You should have received a copy of the GNU General Public License version
.\" 2 along with this work; if not, write to the Free Software Foundation,
.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
.\" or visit www.oracle.com if you need additional information or have any
.\" questions.
.\"
.\" Arch: generic
.\" Software: JDK 8
.\" Date: 21 November 2013
.\" SectDesc: Java IDL and RMI-IIOP Tools
.\" Title: idlj.1
.\"
.if n .pl 99999
.TH idlj 1 "21 November 2013" "JDK 8" "Java IDL and RMI-IIOP Tools"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH NAME
idlj \- Generates Java bindings for a specified Interface Definition Language (IDL) file\&.
.SH SYNOPSIS
.sp
.nf
\fBidlj\fR [ \fIoptions\fR ] \fIidlfile\fR
.fi
.sp
.TP
\fIoptions\fR
The command-line options\&. See Options\&. Options can appear in any order, but must precede the \f3idlfile\fR\&.
.TP
\fIidlfile\fR
The name of a file that contains Interface Definition Language (IDL) definitions\&.
.SH DESCRIPTION
The IDL-to-Java Compiler generates the Java bindings for a specified IDL file\&. For binding details, see Java IDL: IDL to Java Language Mapping at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/idl/mapping/jidlMapping\&.html
.PP
Some earlier releases of the IDL-to-Java compiler were named \f3idltojava\fR\&.
.SS EMIT\ CLIENT\ AND\ SERVER\ BINDINGS
The following \f3idlj\fR command generates an IDL file named \f3My\&.idl\fR with client-side bindings\&.
.sp
.nf
\f3idlj My\&.idl\fP
.fi
.nf
\f3\fR
.fi
.sp
The previous syntax is equivalent to the following:
.sp
.nf
\f3idlj \-fclient My\&.idl\fP
.fi
.nf
\f3\fR
.fi
.sp
The next example generates the server-side bindings, and includes the client-side bindings plus the skeleton, all of which are POA (Inheritance Model)\&.
.sp
.nf
\f3idlg \-fserver My\&.idl\fP
.fi
.nf
\f3\fR
.fi
.sp
If you want to generate both client and server-side bindings, then use one of the following (equivalent) commands:
.sp
.nf
\f3idlj \-fclient \-fserver My\&.idl\fP
.fi
.nf
\f3idlj \-fall My\&.idl\fP
.fi
.nf
\f3\fR
.fi
.sp
There are two possible server-side models: the Portal Servant Inheritance Model and the Tie Model\&. See Tie Delegation Model\&.
.PP
\f3Portable Servant Inheritance Model\fR\&. The default server-side model is the Portable Servant Inheritance Model\&. Given an interface \f3My\fR defined in \f3My\&.idl\fR, the file \f3MyPOA\&.java\fR is generated\&. You must provide the implementation for the \f3My\fR interface, and the \f3My\fR interface must inherit from the \f3MyPOA\fR class\&. \f3MyPOA\&.java\fR is a stream-based skeleton that extends the \f3org\&.omg\&.PortableServer\&.Servant\fR class at http://docs\&.oracle\&.com/javase/8/docs/api/org/omg/PortableServer/Servant\&.html The \f3My\fR interface implements the \f3callHandler\fR interface and the operations interface associated with the IDL interface the skeleton implements\&.The \f3PortableServer\fR module for the Portable Object Adapter (POA) defines the native \f3Servant\fR type\&. See Portable Object Adapter (POA) at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/idl/POA\&.html In the Java programming language, the \f3Servant\fR type is mapped to the Java \f3org\&.omg\&.PortableServer\&.Servant\fR class\&. It serves as the base class for all POA servant implementations and provides a number of methods that can be called by the application programmer, and methods that are called by the POA and that can be overridden by the user to control aspects of servant behavior\&.Another option for the Inheritance Model is to use the \f3-oldImplBase\fR flag to generate server-side bindings that are compatible with releases of the Java programming language before Java SE 1\&.4\&. The -\f3oldImplBase\fR flag is nonstandard, and these APIs are deprecated\&. You would use this flag only for compatibility with existing servers written in Java SE 1\&.3\&. In that case, you would need to modify an existing make file to add the \f3-oldImplBase\fR flag to the \f3idlj\fR compiler\&. Otherwise POA-based server-side mappings are generated\&. To generate server-side bindings that are backward compatible, do the following:
.sp
.nf
\f3idlj \-fclient \-fserver \-oldImplBase My\&.idl\fP
.fi
.nf
\f3idlj \-fall \-oldImplBase My\&.idl\fP
.fi
.nf
\f3\fR
.fi
.sp
Given an interface \f3My\fR defined in \f3My\&.idl\fR, the file \f3_MyImplBase\&.java\fR is generated\&. You must provide the implementation for the \f3My\fR interface, and the \f3My\fR interface must inherit from the \f3_MyImplBase\fR class\&.
.PP
\f3Tie Delegation Model\fR\&. The other server-side model is called the Tie Model\&. This is a delegation model\&. Because it is not possible to generate ties and skeletons at the same time, they must be generated separately\&. The following commands generate the bindings for the Tie Model:
.sp
.nf
\f3idlj \-fall My\&.idl\fP
.fi
.nf
\f3idlj \-fallTIE My\&.idl\fP
.fi
.nf
\f3\fR
.fi
.sp
For the \f3My\fR interface, the second command generates \f3MyPOATie\&.java\fR\&. The constructor to the \f3MyPOATie\fR class takes a delegate\&. In this example, using the default POA model, the constructor also needs a POA\&. You must provide the implementation for the delegate, but it does not have to inherit from any other class, only the interface \f3MyOperations\fR\&. To use it with the ORB, you must wrap your implementation within the \f3MyPOATie\fR class, for example:
.sp
.nf
\f3ORB orb = ORB\&.init(args, System\&.getProperties());\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3// Get reference to rootpoa & activate the POAManager\fP
.fi
.nf
\f3POA rootpoa = (POA)orb\&.resolve_initial_references("RootPOA");\fP
.fi
.nf
\f3rootpoa\&.the_POAManager()\&.activate();\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3// create servant and register it with the ORB\fP
.fi
.nf
\f3MyServant myDelegate = new MyServant();\fP
.fi
.nf
\f3myDelegate\&.setORB(orb); \fP
.fi
.nf
\f3\fR
.fi
.nf
\f3// create a tie, with servant being the delegate\&.\fP
.fi
.nf
\f3MyPOATie tie = new MyPOATie(myDelegate, rootpoa);\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3// obtain the objectRef for the tie\fP
.fi
.nf
\f3My ref = tie\&._this(orb);\fP
.fi
.nf
\f3\fR
.fi
.sp
You might want to use the Tie model instead of the typical Inheritance model when your implementation must inherit from some other implementation\&. Java allows any number of interface inheritance, but there is only one slot for class inheritance\&. If you use the inheritance model, then that slot is used up\&. With the Tie Model, that slot is freed up for your own use\&. The drawback is that it introduces a level of indirection: one extra method call occurs when a method is called\&.
.PP
For server-side generation, Tie model bindings that are compatible with versions of the IDL to Java language mapping in versions earlier than Java SE 1\&.4\&.
.sp
.nf
\f3idlj \-oldImplBase \-fall My\&.idl\fP
.fi
.nf
\f3idlj \-oldImplBase \-fallTIE My\&.idl\fP
.fi
.nf
\f3\fR
.fi
.sp
For the \f3My\fR interface, the this generates \f3My_Tie\&.java\fR\&. The constructor to the \f3My_Tie\fR class takes an \f3impl\fR object\&. You must provide the implementation for \f3impl\fR, but it does not have to inherit from any other class, only the interface \f3HelloOperations\fR\&. But to use it with the ORB, you must wrap your implementation within \f3My_Tie\fR, for example:
.sp
.nf
\f3ORB orb = ORB\&.init(args, System\&.getProperties());\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3// create servant and register it with the ORB\fP
.fi
.nf
\f3MyServant myDelegate = new MyServant();\fP
.fi
.nf
\f3myDelegate\&.setORB(orb); \fP
.fi
.nf
\f3\fR
.fi
.nf
\f3// create a tie, with servant being the delegate\&.\fP
.fi
.nf
\f3MyPOATie tie = new MyPOATie(myDelegate);\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3// obtain the objectRef for the tie\fP
.fi
.nf
\f3My ref = tie\&._this(orb);\fP
.fi
.nf
\f3\fR
.fi
.sp
.SS SPECIFY\ ALTERNATE\ LOCATIONS\ FOR\ EMITTED\ FILES
If you want to direct the emitted files to a directory other than the current directory, then call the compiler this way: \f3i\fR\f3dlj -td /altdir My\&.idl\fR\&.
.PP
For the \f3My\fR interface, the bindings are emitted to \f3/altdir/My\&.java\fR, etc\&., instead of \f3\&./My\&.java\fR\&.
.SS SPECIFY\ ALTERNATE\ LOCATIONS\ FOR\ INCLUDE\ FILES
If the \f3My\&.idl\fR file includes another \f3idl\fR file, \f3MyOther\&.idl\fR, then the compiler assumes that the \f3MyOther\&.idl\fR file resides in the local directory\&. If it resides in \f3/includes\fR, for example, then you call the compiler with the following command:
.sp
.nf
\f3idlj \-i /includes My\&.idl\fP
.fi
.nf
\f3\fR
.fi
.sp
If \f3My\&.idl\fR also included \f3Another\&.idl\fR that resided in \f3/moreIncludes\fR, for example, then you call the compiler with the following command:
.sp
.nf
\f3idlj \-i /includes \-i /moreIncludes My\&.idl\fP
.fi
.nf
\f3\fR
.fi
.sp
Because this form of \f3include\fR can become long, another way to indicate to the compiler where to search for included files is provided\&. This technique is similar to the idea of an environment variable\&. Create a file named idl\&.config in a directory that is listed in your \f3CLASSPATH\fR variable\&. Inside of \f3idl\&.config\fR, provide a line with the following form:
.sp
.nf
\f3includes=/includes;/moreIncludes\fP
.fi
.nf
\f3\fR
.fi
.sp
The compiler will find this file and read in the includes list\&. Note that in this example the separator character between the two directories is a semicolon (;)\&. This separator character is platform dependent\&. On the Windows platform, use a semicolon, on the Unix platform, use a colon, and so on\&.
.SS EMIT\ BINDINGS\ FOR\ INCLUDE\ FILES
By default, only those interfaces, structures, and so on, that are defined in the \f3idl\fR file on the command line have Java bindings generated for them\&. The types defined in included files are not generated\&. For example, assume the following two \f3idl\fR files:
.sp
.nf
\f3My\&.idl file:\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3#include <MyOther\&.idl>\fP
.fi
.nf
\f3interface My\fP
.fi
.nf
\f3{\fP
.fi
.nf
\f3};\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3MyOther\&.idl file:\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3interface MyOther\fP
.fi
.nf
\f3{\fP
.fi
.nf
\f3};\fP
.fi
.nf
\f3\fR
.fi
.sp
There is a caveat to the default rule\&. Any \f3#include\fR statements that appear at the global scope are treated as described\&. These \f3#include\fR statements can be thought of as import statements\&. The \f3#include\fR statements that appear within an enclosed scope are treated as true \f3#include\fR statements, which means that the code within the included file is treated as though it appeared in the original file and, therefore, Java bindings are emitted for it\&. Here is an example:
.sp
.nf
\f3My\&.idl file:\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3#include <MyOther\&.idl>\fP
.fi
.nf
\f3interface My\fP
.fi
.nf
\f3{\fP
.fi
.nf
\f3 #include <Embedded\&.idl>\fP
.fi
.nf
\f3};\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3MyOther\&.idl file:\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3interface MyOther\fP
.fi
.nf
\f3{\fP
.fi
.nf
\f3};\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3Embedded\&.idl\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3enum E {one, two, three};\fP
.fi
.nf
\f3\fR
.fi
.sp
Run\f3idlj My\&.idl\fRto generate the following list of Java files\&. Notice that \f3MyOther\&.java\fR is not generated because it is defined in an import-like \f3#include\fR\&. But \f3E\&.java\fR was generated because it was defined in a true \f3#include\fR\&. Notice that because the \f3Embedded\&.idl\fR file is included within the scope of the interface \f3My\fR, it appears within the scope of \f3My\fR (in \f3MyPackage\fR)\&. If the \f3-emitAll\fR flag had been used, then all types in all included files would have been emitted\&.
.sp
.nf
\f3\&./MyHolder\&.java\fP
.fi
.nf
\f3\&./MyHelper\&.java\fP
.fi
.nf
\f3\&./_MyStub\&.java\fP
.fi
.nf
\f3\&./MyPackage\fP
.fi
.nf
\f3\&./MyPackage/EHolder\&.java\fP
.fi
.nf
\f3\&./MyPackage/EHelper\&.java\fP
.fi
.nf
\f3\&./MyPackage/E\&.java\fP
.fi
.nf
\f3\&./My\&.java\fP
.fi
.nf
\f3\fR
.fi
.sp
.SS INSERT\ PACKAGE\ PREFIXES
Suppose that you work for a company named ABC that has constructed the following IDL file:
.sp
.nf
\f3Widgets\&.idl file:\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3module Widgets\fP
.fi
.nf
\f3{\fP
.fi
.nf
\f3 interface W1 {\&.\&.\&.};\fP
.fi
.nf
\f3 interface W2 {\&.\&.\&.};\fP
.fi
.nf
\f3};\fP
.fi
.nf
\f3\fR
.fi
.sp
If you run this file through the IDL-to-Java compiler, then the Java bindings for W1 and W2 are placed within the \f3Widgets\fR package\&. There is an industry convention that states that a company\&'s packages should reside within a package named \f3com\&.<company name>\fR\&. To follow this convention, the package name should be \f3com\&.abc\&.Widgets\fR\&. To place this package prefix onto the Widgets module, execute the following:
.sp
.nf
\f3idlj \-pkgPrefix Widgets com\&.abc Widgets\&.idl\fP
.fi
.nf
\f3\fR
.fi
.sp
If you have an IDL file that includes Widgets\&.idl, then the \f3-pkgPrefix\fR flag must appear in that command also\&. If it does not, then your IDL file will be looking for a \f3Widgets\fR package rather than a \f3com\&.abc\&.Widgets\fR package\&.
.PP
If you have a number of these packages that require prefixes, then it might be easier to place them into the idl\&.config file described previously\&. Each package prefix line should be of the form: \f3PkgPrefix\&.<type>=<prefix>\fR\&. The line for the previous example would be \f3PkgPrefix\&.Widgets=com\&.abc\fR\&. This option does not affect the Repository ID\&.
.SS DEFINE\ SYMBOLS\ BEFORE\ COMPILATION
You might need to define a symbol for compilation that is not defined within the IDL file, perhaps to include debugging code in the bindings\&. The command \f3idlj -d MYDEF My\&.idl\fRis equivalent to putting the line \f3#define MYDEF\fR inside My\&.idl\&.
.SS PRESERVE\ PREEXISTING\ BINDINGS
If the Java binding files already exist, then the \f3-keep\fR flag keeps the compiler from overwriting them\&. The default is to generate all files without considering that they already exist\&. If you have customized those files (which you should not do unless you are very comfortable with their contents), then the \f3-keep\fR option is very useful\&. The command \f3idlj -keep My\&.idl\fR emits all client-side bindings that do not already exist\&.
.SS VIEW\ COMPILATION\ PROGRESS
The IDL-to-Java compiler generates status messages as it progresses through its phases of execution\&. Use the \f3-v\fR option to activate the verbose mode: \f3idlj -v My\&.idl\fR\&.
.PP
By default the compiler does not operate in verbose mode
.SS DISPLAY\ VERSION\ INFORMATION
To display the build version of the IDL-to-Java compiler, specify the \f3-version\fR option on the command-line: \f3idlj -version\fR\&.
.PP
Version information also appears within the bindings generated by the compiler\&. Any additional options appearing on the command-line are ignored\&.
.SH OPTIONS
.TP
-d \fIsymbol\fR
.br
This is equivalent to the following line in an IDL file:
.sp
.nf
\f3#define \fIsymbol\fR\fP
.fi
.nf
\f3\fR
.fi
.sp
.TP
-demitAll
.br
Emit all types, including those found in \f3#include\fR files\&.
.TP
-fside
.br
Defines what bindings to emit\&. The \f3side\fR parameter can be \f3client\fR, \f3server\fR, \f3serverTIE\fR, \f3all\fR, or \f3allTIE\fR\&. The \f3-fserverTIE\fR and \f3-fallTIE\fR options cause delegate model skeletons to be emitted\&. Defaults to \f3-fclient\fR when the flag is not specified\&.
.TP
-i \fIinclude-path\fR
.br
By default, the current directory is scanned for included files\&. This option adds another directory\&.
.TP
-i \fIkeep\fR
.br
If a file to be generated already exists, then do not overwrite it\&. By default it is overwritten\&.
.TP
-noWarn
.br
Suppress warning messages\&.
.TP
-oldImplBase
.br
Generates skeletons compatible with pre-1\&.4 JDK ORBs\&. By default, the POA Inheritance Model server-side bindings are generated\&. This option provides backward-compatibility with earlier releases of the Java programming language by generating server-side bindings that are \f3ImplBase\fR Inheritance Model classes\&.
.TP
-pkgPrefix \fItype\fR\fIprefix\fR
.br
Wherever \f3type\fR is encountered at file scope, prefix the generated Java package name with \f3prefix\fR for all files generated for that type\&. The type is the simple name of either a top-level module, or an IDL type defined outside of any module\&.
.TP
-pkgTranslate \fItype\fR\fIpackage\fR
.br
Whenever the module name type is encountered in an identifier, replace it in the identifier with package for all files in the generated Java package\&. Note that \f3pkgPrefix\fR changes are made first\&. The type value is the simple name of either a top-level module, or an IDL type defined outside of any module and must match the full package name exactly\&.
If more than one translation matches an identifier, then the longest match is chosen as shown in the following example:
\fICommand\fR:
.sp
.nf
\f3pkgTranslate type pkg \-pkgTranslate type2\&.baz pkg2\&.fizz\fP
.fi
.nf
\f3\fR
.fi
.sp
\fIResulting Translation\fR:
.sp
.nf
\f3type => pkg\fP
.fi
.nf
\f3type\&.ext => pkg\&.ext\fP
.fi
.nf
\f3type\&.baz => pkg2\&.fizz\fP
.fi
.nf
\f3type2\&.baz\&.pkg => pkg2\&.fizz\&.pkg\fP
.fi
.nf
\f3\fR
.fi
.sp
The following package names \f3org\fR, \f3org\fR\&.o\f3mg\fR, or any subpackages of \f3org\&.omg\fR cannot be translated\&. Any attempt to translate these packages results in uncompilable code, and the use of these packages as the first argument after \f3-pkgTranslate\fR is treated as an error\&.
.TP
-skeletonName \fIxxx%yyy\fR
.br
Use \f3xxx%yyy\fR as the pattern for naming the skeleton\&. The defaults are: \f3%POA\fR for the \f3POA\fR base class (\f3-fserver\fR or \f3-fall\fR), and \f3_%ImplBase\fR for the \f3oldImplBase\fR class (-\f3oldImplBase\fR) and (\f3-fserver\fR or \f3-fall\fR))\&.
.TP
-td \fIdir\fR
.br
Use \fIdir\fR for the output directory instead of the current directory\&.
.TP
-tieName \fIxxx%yyy\fR
.br
Use \f3xxx%yyy\fR according to the pattern\&. The defaults are: \f3%POA\fR for the \f3POA\fR base class (\f3-fserverTie or -fallTie\fR), and \f3_%Tie\fR for the \f3oldImplBase\fR tie class (-\f3oldImplBase\fR) and (\f3-fserverTie\fR or \f3-fallTie\fR))
.TP
-nowarn, -verbose
.br
Displays release information and terminates\&.
.TP
-version
.br
Displays release information and terminates\&.
.SH RESTRICTIONS
Escaped identifiers in the global scope cannot have the same spelling as IDL primitive types, \f3Object\fR, or \f3ValueBase\fR\&. This is because the symbol table is preloaded with these identifiers\&. Allowing them to be redefined would overwrite their original definitions\&. Possible permanent restriction\&.
.PP
The \f3fixed\fR IDL type is not supported\&.
.SH KNOWN\ PROBLEMS
No import is generated for global identifiers\&. If you call an unexported local \f3impl\fR object, then you do get an exception, but it seems to be due to a \f3NullPointerException\fR in the \f3ServerDelegate\fR DSI code\&.
.RE
.br
'pl 8.5i
'bp

View file

@ -1,24 +0,0 @@
." Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
."
." This code is free software; you can redistribute it and/or modify it
." under the terms of the GNU General Public License version 2 only, as
." published by the Free Software Foundation.
."
." This code 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 General Public License
." version 2 for more details (a copy is included in the LICENSE file that
." accompanied this code).
."
." You should have received a copy of the GNU General Public License version
." 2 along with this work; if not, write to the Free Software Foundation,
." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
."
." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
." or visit www.oracle.com if you need additional information or have any
." questions.
."
.TH idlj 1 "07 May 2011"
.LP

View file

@ -1,24 +0,0 @@
." Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
."
." This code is free software; you can redistribute it and/or modify it
." under the terms of the GNU General Public License version 2 only, as
." published by the Free Software Foundation.
."
." This code 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 General Public License
." version 2 for more details (a copy is included in the LICENSE file that
." accompanied this code).
."
." You should have received a copy of the GNU General Public License version
." 2 along with this work; if not, write to the Free Software Foundation,
." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
."
." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
." or visit www.oracle.com if you need additional information or have any
." questions.
."
.TH orbd 1 "07 May 2011"
.LP

View file

@ -1,24 +0,0 @@
." Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
."
." This code is free software; you can redistribute it and/or modify it
." under the terms of the GNU General Public License version 2 only, as
." published by the Free Software Foundation.
."
." This code 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 General Public License
." version 2 for more details (a copy is included in the LICENSE file that
." accompanied this code).
."
." You should have received a copy of the GNU General Public License version
." 2 along with this work; if not, write to the Free Software Foundation,
." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
."
." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
." or visit www.oracle.com if you need additional information or have any
." questions.
."
.TH schemagen 1 "07 May 2011"
.LP

View file

@ -1,24 +0,0 @@
." Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
."
." This code is free software; you can redistribute it and/or modify it
." under the terms of the GNU General Public License version 2 only, as
." published by the Free Software Foundation.
."
." This code 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 General Public License
." version 2 for more details (a copy is included in the LICENSE file that
." accompanied this code).
."
." You should have received a copy of the GNU General Public License version
." 2 along with this work; if not, write to the Free Software Foundation,
." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
."
." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
." or visit www.oracle.com if you need additional information or have any
." questions.
."
.TH servertool 1 "07 May 2011"
.LP

View file

@ -1,24 +0,0 @@
." Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
."
." This code is free software; you can redistribute it and/or modify it
." under the terms of the GNU General Public License version 2 only, as
." published by the Free Software Foundation.
."
." This code 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 General Public License
." version 2 for more details (a copy is included in the LICENSE file that
." accompanied this code).
."
." You should have received a copy of the GNU General Public License version
." 2 along with this work; if not, write to the Free Software Foundation,
." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
."
." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
." or visit www.oracle.com if you need additional information or have any
." questions.
."
.TH tnameserv 1 "07 May 2011"
.LP

View file

@ -1,22 +0,0 @@
." Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
."
." This code is free software; you can redistribute it and/or modify it
." under the terms of the GNU General Public License version 2 only, as
." published by the Free Software Foundation.
."
." This code 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 General Public License
." version 2 for more details (a copy is included in the LICENSE file that
." accompanied this code).
."
." You should have received a copy of the GNU General Public License version
." 2 along with this work; if not, write to the Free Software Foundation,
." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
."
." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
." or visit www.oracle.com if you need additional information or have any
." questions.
."
.TH wsgen 1 "07 May 2011"

View file

@ -1,22 +0,0 @@
." Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
."
." This code is free software; you can redistribute it and/or modify it
." under the terms of the GNU General Public License version 2 only, as
." published by the Free Software Foundation.
."
." This code 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 General Public License
." version 2 for more details (a copy is included in the LICENSE file that
." accompanied this code).
."
." You should have received a copy of the GNU General Public License version
." 2 along with this work; if not, write to the Free Software Foundation,
." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
."
." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
." or visit www.oracle.com if you need additional information or have any
." questions.
."
.TH wsimport 1 "07 May 2011"

View file

@ -1,25 +0,0 @@
." Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
."
." This code is free software; you can redistribute it and/or modify it
." under the terms of the GNU General Public License version 2 only, as
." published by the Free Software Foundation.
."
." This code 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 General Public License
." version 2 for more details (a copy is included in the LICENSE file that
." accompanied this code).
."
." You should have received a copy of the GNU General Public License version
." 2 along with this work; if not, write to the Free Software Foundation,
." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
."
." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
." or visit www.oracle.com if you need additional information or have any
." questions.
."
.TH xjc 1 "07 May 2011"
.LP
.ad c

View file

@ -1,213 +0,0 @@
'\" t
.\" Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
.\"
.\" This code is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License version 2 only, as
.\" published by the Free Software Foundation.
.\"
.\" This code 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 General Public License
.\" version 2 for more details (a copy is included in the LICENSE file that
.\" accompanied this code).
.\"
.\" You should have received a copy of the GNU General Public License version
.\" 2 along with this work; if not, write to the Free Software Foundation,
.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
.\" or visit www.oracle.com if you need additional information or have any
.\" questions.
.\"
.\" Arch: generic
.\" Software: JDK 8
.\" Date: 21 November 2013
.\" SectDesc: Java IDL and RMI-IIOP Tools
.\" Title: orbd.1
.\"
.if n .pl 99999
.TH orbd 1 "21 November 2013" "JDK 8" "Java IDL and RMI-IIOP Tools"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH NAME
orbd \- Enables clients to locate and call persistent objects on servers in the CORBA environment\&.
.SH SYNOPSIS
.sp
.nf
\fBorbd\fR [ \fIoptions\fR ]
.fi
.sp
.TP
\fIoptions\fR
Command-line options\&. See Options\&.
.SH DESCRIPTION
The \f3orbd\fR command enables clients to transparently locate and call persistent objects on servers in the CORBA environment\&. The Server Manager included with the orbd tool is used to enable clients to transparently locate and call persistent objects on servers in the CORBA environment\&. The persistent servers, while publishing the persistent object references in the naming service, include the port number of the ORBD in the object reference instead of the port number of the server\&. The inclusion of an ORBD port number in the object reference for persistent object references has the following advantages:
.TP 0.2i
\(bu
The object reference in the naming service remains independent of the server life cycle\&. For example, the object reference could be published by the server in the Naming Service when it is first installed, and then, independent of how many times the server is started or shut down, the ORBD returns the correct object reference to the calling client\&.
.TP 0.2i
\(bu
The client needs to look up the object reference in the naming service only once, and can keep reusing this reference independent of the changes introduced due to server life cycle\&.
.PP
To access the ORBD Server Manager, the server must be started using \f3servertool\fR, which is a command-line interface for application programmers to register, unregister, start up, and shut down a persistent server\&. For more information on the Server Manager, see Server Manager\&.
.PP
When \f3orbd\fR starts, it also starts a naming service\&. For more information about the naming service\&. See Start and Stop the Naming Service\&.
.SH OPTIONS
.TP
-ORBInitialPort \fInameserverport\fR
.br
Required\&. Specifies the port on which the name server should be started\&. After it is started, \f3orbd\fR listens for incoming requests on this port\&. On Oracle Solaris software, you must become the root user to start a process on a port below 1024\&. For this reason, Oracle recommends that you use a port number above or equal to 1024\&.
.SS NONREQUIRED\ OPTIONS
.TP
-port \fIport\fR
.br
Specifies the activation port where ORBD should be started, and where ORBD will be accepting requests for persistent objects\&. The default value for this port is 1049\&. This port number is added to the port field of the persistent Interoperable Object References (IOR)\&.
.TP
-defaultdb \fIdirectory\fR
.br
Specifies the base where the ORBD persistent storage directory, \f3orb\&.db\fR, is created\&. If this option is not specified, then the default value is \f3\&./orb\&.db\fR\&.
.TP
-serverPollingTime \fImilliseconds\fR
.br
Specifies how often ORBD checks for the health of persistent servers registered through \f3servertool\fR\&. The default value is 1000 ms\&. The value specified for \f3milliseconds\fR must be a valid positive integer\&.
.TP
-serverStartupDelay milliseconds
.br
Specifies how long ORBD waits before sending a location forward exception after a persistent server that is registered through \f3servertool\fR is restarted\&. The default value is 1000 ms\&. The value specified for \f3milliseconds\fR must be a valid positive integer\&.
.TP
-J\fIoption\fR
.br
Passes \f3option\fR to the Java Virtual Machine, where \f3option\fR is one of the options described on the reference page for the Java application launcher\&. For example, \f3-J-Xms48m\fR sets the startup memory to 48 MB\&. See java(1)\&.
.SS START\ AND\ STOP\ THE\ NAMING\ SERVICE
A naming service is a CORBA service that allows CORBA objects to be named by means of binding a name to an object reference\&. The name binding can be stored in the naming service, and a client can supply the name to obtain the desired object reference\&.
.PP
Before running a client or a server, you will start ORBD\&. ORBD includes a persistent naming service and a transient naming service, both of which are an implementation of the COS Naming Service\&.
.PP
The Persistent Naming Service provides persistence for naming contexts\&. This means that this information is persistent across service shutdowns and startups, and is recoverable in the event of a service failure\&. If ORBD is restarted, then the Persistent Naming Service restores the naming context graph, so that the binding of all clients\&' and servers\&' names remains intact (persistent)\&.
.PP
For backward compatibility, \f3tnameserv\fR, a Transient Naming Service that shipped with earlier releases of the JDK, is also included in this release of Java SE\&. A transient naming service retains naming contexts as long as it is running\&. If there is a service interruption, then the naming context graph is lost\&.
.PP
The \f3-ORBInitialPort\fR argument is a required command-line argument for \f3orbd\fR, and is used to set the port number on which the naming service runs\&. The following instructions assume you can use port 1050 for the Java IDL Object Request Broker Daemon\&. When using Oracle Solaris software, you must become a root user to start a process on a port lower than 1024\&. For this reason, it is recommended that you use a port number above or equal to 1024\&. You can substitute a different port when necessary\&.
.PP
To start \f3orbd\fR from a UNIX command shell, enter:
.sp
.nf
\f3orbd \-ORBInitialPort 1050&\fP
.fi
.nf
\f3\fP
.fi
.sp
From an MS-DOS system prompt (Windows), enter:
.sp
.nf
\f3start orbd \-ORBInitialPort 1050\fP
.fi
.nf
\f3\fP
.fi
.sp
Now that ORBD is running, you can run your server and client applications\&. When running the client and server applications, they must be made aware of the port number (and machine name, when applicable) where the Naming Service is running\&. One way to do this is to add the following code to your application:
.sp
.nf
\f3Properties props = new Properties();\fP
.fi
.nf
\f3props\&.put("org\&.omg\&.CORBA\&.ORBInitialPort", "1050");\fP
.fi
.nf
\f3props\&.put("org\&.omg\&.CORBA\&.ORBInitialHost", "MyHost");\fP
.fi
.nf
\f3ORB orb = ORB\&.init(args, props);\fP
.fi
.nf
\f3\fP
.fi
.sp
In this example, the naming service is running on port 1050 on host \f3MyHost\fR\&. Another way is to specify the port number and/or machine name when running the server or client application from the command line\&. For example, you would start your \f3HelloApplication\fR with the following command line:
.sp
.nf
\f3java HelloApplication \-ORBInitialPort 1050 \-ORBInitialHost MyHost\fP
.fi
.nf
\f3\fP
.fi
.sp
To stop the naming service, use the relevant operating system command, such as \f3pkill\fR\f3orbd\fR on Oracle Solaris, or \fICtrl+C\fR in the DOS window in which \f3orbd\fR is running\&. Note that names registered with the naming service can disappear when the service is terminated because of a transient naming service\&. The Java IDL naming service will run until it is explicitly stopped\&.
.PP
For more information about the naming service included with ORBD, see Naming Service at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/idl/jidlNaming\&.html
.SH SERVER\ MANAGER
To access the ORBD Server Manager and run a persistent server, the server must be started with \f3servertool\fR, which is a command-line interface for application programmers to register, unregister, start up, and shut down a persistent server\&. When a server is started using \f3servertool\fR, it must be started on the same host and port on which \f3orbd\fR is executing\&. If the server is run on a different port, then the information stored in the database for local contexts will be invalid and the service will not work properly\&.
.PP
See Java IDL: The "Hello World" Example at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/idl/jidlExample\&.html
.PP
In this example, you run the \f3idlj\fR compiler and \f3javac\fR compiler as shown in the tutorial\&. To run the ORBD Server Manager, follow these steps for running the application:
.PP
Start \f3orbd\fR\&.
.PP
UNIX command shell, enter: \f3orbd -ORBInitialPort 1050\fR\&.
.PP
MS-DOS system prompt (Windows), enter: \f3s\fR\f3tart orbd -ORBInitialPort 105\fR\f30\fR\&.
.PP
Port 1050 is the port on which you want the name server to run\&. The \f3-ORBInitialPort\fR option is a required command-line argument\&. When using Oracle Solaris software, you must become a root user to start a process on a port below 1024\&. For this reason, it is recommended that you use a port number above or equal to 1024\&.
.PP
Start the \f3servertool\fR: \f3servertool -ORBInitialPort 1050\fR\&.
.PP
Make sure the name server (\f3orbd\fR) port is the same as in the previous step, for example, \f3-ORBInitialPort 1050\&.\fR The \f3servertool\fR must be started on the same port as the name server\&.
.PP
In the \f3servertool\fR command line interface, start the \f3Hello\fR server from the \f3servertool\fR prompt:
.sp
.nf
\f3servertool > register \-server HelloServer \-classpath \&. \-applicationName\fP
.fi
.nf
\f3 HelloServerApName\fP
.fi
.nf
\f3\fP
.fi
.sp
The \f3servertool\fR registers the server, assigns it the name \f3HelloServerApName\fR, and displays its server ID with a listing of all registered servers\&.Run the client application from another terminal window or prompt:
.sp
.nf
\f3java HelloClient \-ORBInitialPort 1050 \-ORBInitialHost localhost\fP
.fi
.nf
\f3\fP
.fi
.sp
For this example, you can omit \f3-ORBInitialHost localhost\fR because the name server is running on the same host as the \f3Hello\fR client\&. If the name server is running on a different host, then use the -\f3ORBInitialHost nameserverhost\fR option to specify the host on which the IDL name server is running\&.Specify the name server (\f3orbd\fR) port as done in the previous step, for example, \f3-ORBInitialPort 1050\fR\&. When you finish experimenting with the ORBD Server Manager, be sure to shut down or terminate the name server (\f3orbd\fR) and \f3servertool\fR\&. To shut down \f3orbd\fR from am MS-DOS prompt, select the window that is running the server and enter \fICtrl+C\fR to shut it down\&.
.PP
To shut down \f3orbd\fR from an Oracle Solaris shell, find the process, and terminate with the \f3kill\fR command\&. The server continues to wait for invocations until it is explicitly stopped\&. To shut down the \f3servertool\fR, type \fIquit\fR and press the \fIEnter\fR key\&.
.SH SEE\ ALSO
.TP 0.2i
\(bu
servertool(1)
.TP 0.2i
\(bu
Naming Service at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/idl/jidlNaming\&.html
.RE
.br
'pl 8.5i
'bp

View file

@ -1,121 +0,0 @@
'\" t
.\" Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
.\"
.\" This code is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License version 2 only, as
.\" published by the Free Software Foundation.
.\"
.\" This code 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 General Public License
.\" version 2 for more details (a copy is included in the LICENSE file that
.\" accompanied this code).
.\"
.\" You should have received a copy of the GNU General Public License version
.\" 2 along with this work; if not, write to the Free Software Foundation,
.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
.\" or visit www.oracle.com if you need additional information or have any
.\" questions.
.\"
.\" Arch: generic
.\" Software: JDK 8
.\" Date: 21 November 2013
.\" SectDesc: Java Web Services Tools
.\" Title: schemagen.1
.\"
.if n .pl 99999
.TH schemagen 1 "21 November 2013" "JDK 8" "Java Web Services Tools"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH NAME
schemagen \- Generates a schema for every name space that is referenced in your Java classes\&.
.SH SYNOPSIS
.sp
.nf
\fBschemagen\fR [ \fIoptions\fR ] \fIjava\-files\fR
.fi
.sp
.TP
\fIoptions\fR
The command-line options\&. See Options\&.
.TP
\fIjava-files\fR
The Java class files to be processed\&.
.SH DESCRIPTION
The schema generator creates a schema file for each name space referenced in your Java classes\&. Currently, you cannot control the name of the generated schema files\&. To control the schema file names, see Using SchemaGen with Ant at http://jaxb\&.java\&.net/nonav/2\&.2\&.3u1/docs/schemagenTask\&.html
.PP
Start the schema generator with the appropriate \f3schemagen\fR shell script in the bin directory for your platform\&. The current schema generator can process either Java source files or class files\&.
.sp
.nf
\f3schemagen\&.sh Foo\&.java Bar\&.java \&.\&.\&.\fP
.fi
.nf
\f3Note: Writing schema1\&.xsd\fP
.fi
.nf
\f3\fP
.fi
.sp
If your java files reference other classes, then those classes must be accessible on your system \f3CLASSPATH\fR environment variable, or they need to be specified in the \f3schemagen\fR command line with the class path options\&. See Options\&. If the referenced files are not accessible or specified, then you get errors when you generate the schema\&.
.SH OPTIONS
.TP
-d \fIpath\fR
.br
The location where the \f3schemagen\fR command places processor-generated and \f3javac\fR-generated class files\&.
.TP
-cp \fIpath\fR
.br
The location where the \f3schemagen\fR command places user-specified files\&.
.TP
-classpath \fIpath\fR
.br
The location where the \f3schemagen\fR command places user-specified files\&.
.TP
-encoding \fIencoding\fR
.br
Specifies the encoding to use for \f3apt\fR or \f3javac\fR command invocations\&.
.TP
-episode \fIfile\fR
.br
Generates an episode file for separate compilation\&.
.TP
-version
.br
Displays release information\&.
.TP
-help
.br
Displays a help message\&.
.SH SEE\ ALSO
.TP 0.2i
\(bu
Using SchemaGen with Ant at http://jaxb\&.java\&.net/nonav/2\&.2\&.3u1/docs/schemagenTask\&.html
.TP 0.2i
\(bu
Java Architecture for XML Binding (JAXB) at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/xml/jaxb/index\&.html
.RE
.br
'pl 8.5i
'bp

View file

@ -1,137 +0,0 @@
'\" t
.\" Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
.\"
.\" This code is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License version 2 only, as
.\" published by the Free Software Foundation.
.\"
.\" This code 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 General Public License
.\" version 2 for more details (a copy is included in the LICENSE file that
.\" accompanied this code).
.\"
.\" You should have received a copy of the GNU General Public License version
.\" 2 along with this work; if not, write to the Free Software Foundation,
.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
.\" or visit www.oracle.com if you need additional information or have any
.\" questions.
.\"
.\" Arch: generic
.\" Software: JDK 8
.\" Date: 21 November 2013
.\" SectDesc: Java IDL and RMI-IIOP Tools
.\" Title: servertool.1
.\"
.if n .pl 99999
.TH servertool 1 "21 November 2013" "JDK 8" "Java IDL and RMI-IIOP Tools"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH NAME
servertool \- Provides an easy-to-use interface for developers to register, unregister, start up, and shut down a persistent server\&.
.SH SYNOPSIS
.sp
.nf
\fBservertool\fR \-ORBInitialPort \fInameserverport\fR [ \fIoptions\fR ] [ \fIcommands \fR]
.fi
.sp
.TP
\fIoptions\fR
The command-line options\&. See Options\&.
.TP
commands
The command-line commands\&. See Commands\&.
.SH DESCRIPTION
The \f3servertool\fR command provides the command-line interface for developers to register, unregister, start up, and shut down a persistent server\&. Command-line commands let you obtain various statistical information about the server\&. See Commands\&.
.SH OPTIONS
.TP
-ORBInitialHost \fInameserverhost\fR
.br
This options is required\&. It specifies the host machine on which the name server runs and listens for incoming requests\&. The \f3nameserverhost\fR value must specify the port on which the \f3orb\fR is running and listening for requests\&. The value defaults to \f3localhost\fR when this option is not specified\&. If \f3orbd\fR and \f3servertool\fR are running on different machines, then you must specify the name or IP address of the host on which \f3orbd\fR is running\&.
\fINote:\fR On Oracle Solaris, you must become a root user to start a process on a port below 1024\&. Oracle recommends that you use a port number above or equal to 1024 for the \f3nameserverport\fR value\&.
.TP
-J\fIoption\fR
.br
Passes \f3option\fR to the Java Virtual Machine, where \f3option\fR is one of the options described on the reference page for the Java application launcher\&. For example, \f3-J-Xms48m\fR sets the startup memory to 48 MB\&. See java(1)\&.
.SH COMMANDS
You can start the \f3servertool\fR command with or without a command-line command\&.
.TP 0.2i
\(bu
If you did not specify a command when you started \f3servertool\fR, then the command-line tool displays the \f3servertool\fR prompt where you can enter commands: \f3servertool >\fR\&.
.TP 0.2i
\(bu
If you specify a command when you start \f3servertool\fR, then the Java IDL Server Tool starts, executes the command, and exits\&.
.TP
.ll 180
register -server \fIserver-class-name\fR -classpath \fIclasspath-to-server\fR [ -applicationName \fIapplication-name\fR -args \fIargs-to-server\fR -vmargs \fIflags-for-JVM\fR ]
Registers a new persistent server with the Object Request Broker Daemon (ORBD)\&. If the server is not already registered, then it is registered and activated\&. This command causes an installation method to be called in the \f3main\fR class of the server identified by the \f3-server\fR option\&. The installation method must be \f3public static void install(org\&.omg\&.CORBA\&.ORB)\fR\&. The install method is optional and lets developers provide their own server installation behavior, such as creating a database schema\&.
.TP
.ll 180
unregister -serverid \fIserver-id\fR | -applicationName \fIapplication-name\fR
Unregisters a server from the ORBD with either its server ID or its application name\&. This command causes an uninstallation method to be called in the \f3main\fR class of the server identified by the \f3-server\fR option\&. The \f3uninstall\fR method must be \f3public static void uninstall(org\&.omg\&.CORBA\&.ORB)\fR\&. The \f3uninstall\fR method is optional and lets developers provide their own server uninstallation behavior, such as undoing the behavior of the \f3install\fR method\&.
.TP
getserverid -applicationName \fIapplication-name\fR
Returns the server ID that corresponds to the \f3application-name\fR value\&.
.TP
list
Lists information about all persistent servers registered with the ORBD\&.
.TP
listappnames
Lists the application names for all servers currently registered with the ORBD\&.
.TP
listactive
Lists information about all persistent servers that were started by the ORBD and are currently running\&.
.TP
.ll 180
locate -serverid \fIserver-id\fR | -applicationName \fIapplication-name\fR [ -endpointType \fIendpointType\fR ]
Locates the endpoints (ports) of a specific type for all ORBs created by a registered server\&. If a server is not already running, then it is activated\&. If an \f3endpointType\fR value is not specified, then the plain/non-protected endpoint associated with each ORB in a server is returned\&.
.TP
.ll 180
locateperorb -serverid \fIserver-id\fR | -applicationName \fIapplication-name\fR [ -orbid \fIORB-name\fR ]
Locates all the endpoints (ports) registered by a specific Object Request Broker (ORB) of registered server\&. If a server is not already running, then it is activated\&. If an \f3orbid\fR is not specified, then the default value of \f3""\fR is assigned to the \f3orbid\fR\&. If any ORBs are created with an \f3orbid\fR of empty string, then all ports registered by it are returned\&.
.TP
orblist -serverid \fIserver-id\fR | -applicationName \fIapplication-name\fR
Lists the \f3ORBId\fR of the ORBs defined on a server\&. An \f3ORBId\fR is the string name for the ORB created by the server\&. If the server is not already running, then it is activated\&.
.TP
shutdown -serverid \fIserver-id\fR | -applicationName application-name
Shut down an active server that is registered with ORBD\&. During execution of this command, the \f3shutdown\fR method defined in the class specified by either the \f3-serverid\fR or \f3-applicationName\fR parameter is also called to shut down the server process\&.
.TP
startup -serverid \fIserver-id\fR | -applicationName application-name
Starts up or activate a server that is registered with ORBD\&. If the server is not running, then this command starts the server\&. If the server is already running, then an error message is displayed\&.
.TP
help
Lists all the commands available to the server through the \f3servertool\fR command\&.
.TP
quit
Exits the \f3servertool\fR command\&.
.SH SEE\ ALSO
.TP 0.2i
\(bu
orbd(1)
.RE
.br
'pl 8.5i
'bp

View file

@ -1,488 +0,0 @@
'\" t
.\" Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
.\"
.\" This code is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License version 2 only, as
.\" published by the Free Software Foundation.
.\"
.\" This code 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 General Public License
.\" version 2 for more details (a copy is included in the LICENSE file that
.\" accompanied this code).
.\"
.\" You should have received a copy of the GNU General Public License version
.\" 2 along with this work; if not, write to the Free Software Foundation,
.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
.\" or visit www.oracle.com if you need additional information or have any
.\" questions.
.\"
.\" Arch: generic
.\" Software: JDK 8
.\" Date: 21 November 2013
.\" SectDesc: Java IDL and RMI-IIOP Tools
.\" Title: tnameserv.1
.\"
.if n .pl 99999
.TH tnameserv 1 "21 November 2013" "JDK 8" "Java IDL and RMI-IIOP Tools"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH NAME
tnameserv \- Interface Definition Language (IDL)\&.
.SH SYNOPSIS
.sp
.nf
\fBtnameserve\fR \fB\-ORBInitialPort\fR [ \fInameserverport\fR ]
.fi
.sp
.TP
-ORBInitialPort \fInameserverport\fR
.br
The initial port where the naming service listens for the bootstrap protocol used to implement the ORB \f3resolve_initial_references\fR and \f3list_initial_references\fR methods\&.
.SH DESCRIPTION
Java IDL includes the Object Request Broker Daemon (ORBD)\&. ORBD is a daemon process that contains a Bootstrap Service, a Transient Naming Service, a Persistent Naming Service, and a Server Manager\&. The Java IDL tutorials all use ORBD, but you can substitute the \f3tnameserv\fR command for the \f3orbd\fR command in any of the examples that use a Transient Naming Service\&.
.PP
See orbd(1) or Naming Service at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/idl/jidlNaming\&.html
.PP
The CORBA Common Object Services (COS) Naming Service provides a tree-structure directory for object references similar to a file system that provides a directory structure for files\&. The Transient Naming Service provided with Java IDL, \f3tnameserv\fR, is a simple implementation of the COS Naming Service specification\&.
.PP
Object references are stored in the name space by name and each object reference-name pair is called a name binding\&. Name bindings can be organized under naming contexts\&. Naming contexts are name bindings and serve the same organizational function as a file system subdirectory\&. All bindings are stored under the initial naming context\&. The initial naming context is the only persistent binding in the name space\&. The rest of the name space is lost when the Java IDL naming service process stops and restarts\&.
.PP
For an applet or application to use COS naming, its ORB must know the port of a host running a naming service or have access to an initial naming context string for that naming service\&. The naming service can either be the Java IDL naming service or another COS-compliant naming service\&.
.SS START\ THE\ NAMING\ SERVICE
You must start the Java IDL naming service before an application or applet that uses its naming service\&. Installation of the Java IDL product creates a script (Oracle Solaris: \f3tnameserv\fR) or executable file (Windows: \f3tnameserv\&.exe\fR) that starts the Java IDL naming service\&. Start the naming service so it runs in the background\&.
.PP
If you do not specify otherwise, then the Java IDL naming service listens on port 900 for the bootstrap protocol used to implement the ORB \f3resolve_initial_references\fR and \f3list_initial_references methods\fR, as follows:
.sp
.nf
\f3tnameserv \-ORBInitialPort nameserverport&\fP
.fi
.nf
\f3\fP
.fi
.sp
If you do not specify the name server port, then port 900 is used by default\&. When running Oracle Solaris software, you must become the root user to start a process on a port below 1024\&. For this reason, it is recommended that you use a port number greater than or equal to 1024\&. To specify a different port, for example, 1050, and to run the naming service in the background, from a UNIX command shell, enter:
.sp
.nf
\f3tnameserv \-ORBInitialPort 1050&\fP
.fi
.nf
\f3\fP
.fi
.sp
From an MS-DOS system prompt (Windows), enter:
.sp
.nf
\f3start tnameserv \-ORBInitialPort 1050\fP
.fi
.nf
\f3\fP
.fi
.sp
Clients of the name server must be made aware of the new port number\&. Do this by setting the \f3org\&.omg\&.CORBA\&.ORBInitialPort\fR property to the new port number when you create the ORB object\&.
.SS RUN\ THE\ SERVER\ AND\ CLIENT\ ON\ DIFFERENT\ HOSTS
In most of the Java IDL and RMI-IIOP tutorials, the naming service, server, and client are all running on the development machine\&. In real-world deployment, the client and server probably run on different host machines from the Naming Service\&.
.PP
For the client and server to find the Naming Service, they must be made aware of the port number and host on which the naming service is running\&. Do this by setting the \f3org\&.omg\&.CORBA\&.ORBInitialPort\fR and \f3org\&.omg\&.CORBA\&.ORBInitialHost\fR properties in the client and server files to the machine name and port number on which the Naming Service is running\&. An example of this is shown in Getting Started Using RMI-IIOP at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/rmi-iiop/rmiiiopexample\&.html
.PP
You could also use the command-line options \f3-ORBInitialPort nameserverport#\fR and \f3-ORBInitialHost nameserverhostname\fR to tell the client and server where to find the naming service\&. For one example of doing this using the command-line option, see Java IDL: The Hello World Example on Two Machines at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/idl/tutorial/jidl2machines\&.html
.PP
For example, suppose the Transient Naming Service, \f3tnameserv\fR is running on port 1050 on host \f3nameserverhost\fR\&. The client is running on host \f3clienthost,\fR and the server is running on host \f3serverhost\fR\&.
.PP
Start \f3tnameserv\fR on the host \f3nameserverhost\fR:
.sp
.nf
\f3tnameserv \-ORBInitialPort 1050\fP
.fi
.nf
\f3\fP
.fi
.sp
Start the server on the \f3serverhost\fR:
.sp
.nf
\f3java Server \-ORBInitialPort 1050 \-ORBInitialHost nameserverhost\fP
.fi
.nf
\f3\fP
.fi
.sp
Start the client on the \f3clienthost\fR:
.sp
.nf
\f3java Client \-ORBInitialPort 1050 \-ORBInitialHost nameserverhost\fP
.fi
.nf
\f3\fP
.fi
.sp
.SS STOP\ THE\ NAMING\ SERVICE
To stop the Java IDL naming service, use the relevant operating system command, such as \f3kill\fR for a Unix process or \f3Ctrl+C\fR for a Windows process\&. The naming service continues to wait for invocations until it is explicitly shut down\&. Note that names registered with the Java IDL naming service disappear when the service is terminated\&.
.SH OPTIONS
.TP
-J\fIoption\fR
.br
Passes \f3option\fR to the Java Virtual Machine, where \f3option\fR is one of the options described on the reference page for the Java application launcher\&. For example, \f3-J-Xms48m\fR sets the startup memory to 48 MB\&. See java(1)\&.
.SH EXAMPLES
.SS ADD\ OBJECTS\ TO\ THE\ NAME\ SPACE
The following example shows how to add names to the name space\&. It is a self-contained Transient Naming Service client that creates the following simple tree\&.
.sp
.nf
\f3Initial Naming Context\fP
.fi
.nf
\f3 plans\fP
.fi
.nf
\f3 Personal\fP
.fi
.nf
\f3 calendar\fP
.fi
.nf
\f3 schedule\fP
.fi
.nf
\f3\fP
.fi
.sp
In this example, \f3plans\fR is an object reference and \f3Personal\fR is a naming context that contains two object references: \f3calendar\fR and \f3schedule\fR\&.
.sp
.nf
\f3import java\&.util\&.Properties;\fP
.fi
.nf
\f3import org\&.omg\&.CORBA\&.*;\fP
.fi
.nf
\f3import org\&.omg\&.CosNaming\&.*;\fP
.fi
.nf
\f3\fP
.fi
.nf
\f3public class NameClient {\fP
.fi
.nf
\f3\fP
.fi
.nf
\f3 public static void main(String args[]) {\fP
.fi
.nf
\f3\fP
.fi
.nf
\f3 try {\fP
.fi
.nf
\f3\fP
.fi
.sp
In Start the Naming Service, the \f3nameserver\fR was started on port 1050\&. The following code ensures that the client program is aware of this port number\&.
.sp
.nf
\f3 Properties props = new Properties();\fP
.fi
.nf
\f3 props\&.put("org\&.omg\&.CORBA\&.ORBInitialPort", "1050");\fP
.fi
.nf
\f3 ORB orb = ORB\&.init(args, props);\fP
.fi
.nf
\f3\fP
.fi
.sp
This code obtains the initial naming context and assigns it to \f3ctx\fR\&. The second line copies \f3ctx\fR into a dummy object reference \f3objref\fR that is attached to various names and added into the name space\&.
.sp
.nf
\f3 NamingContext ctx =\fP
.fi
.nf
\f3 NamingContextHelper\&.narrow(\fP
.fi
.nf
\f3 orb\&.resolve_initial_references("NameService"));\fP
.fi
.nf
\f3 NamingContext objref = ctx;\fP
.fi
.nf
\f3\fP
.fi
.sp
This code creates a name \f3plans\fR of type \f3text\fR and binds it to the dummy object reference\&. \f3plans\fR is then added under the initial naming context using the \f3rebind\fR method\&. The \f3rebind\fR method enables you to run this program over and over again without getting the exceptions from using the \f3bind\fR method\&.
.sp
.nf
\f3 NameComponent nc1 = new NameComponent("plans", "text");\fP
.fi
.nf
\f3 NameComponent[] name1 = {nc1};\fP
.fi
.nf
\f3 ctx\&.rebind(name1, objref);\fP
.fi
.nf
\f3 System\&.out\&.println("plans rebind successful!");\fP
.fi
.nf
\f3\fP
.fi
.sp
This code creates a naming context called \f3Personal\fR of type \f3directory\fR\&. The resulting object reference, \f3ctx2\fR, is bound to the \f3name\fR and added under the initial naming context\&.
.sp
.nf
\f3 NameComponent nc2 = new NameComponent("Personal", "directory");\fP
.fi
.nf
\f3 NameComponent[] name2 = {nc2};\fP
.fi
.nf
\f3 NamingContext ctx2 = ctx\&.bind_new_context(name2);\fP
.fi
.nf
\f3 System\&.out\&.println("new naming context added\&.\&.");\fP
.fi
.nf
\f3\fP
.fi
.sp
The remainder of the code binds the dummy object reference using the names \f3schedule\fR and \f3calendar\fR under the \f3Personal\fR naming context (\f3ctx2\fR)\&.
.sp
.nf
\f3 NameComponent nc3 = new NameComponent("schedule", "text");\fP
.fi
.nf
\f3 NameComponent[] name3 = {nc3};\fP
.fi
.nf
\f3 ctx2\&.rebind(name3, objref);\fP
.fi
.nf
\f3 System\&.out\&.println("schedule rebind successful!");\fP
.fi
.nf
\f3\fP
.fi
.nf
\f3 NameComponent nc4 = new NameComponent("calender", "text");\fP
.fi
.nf
\f3 NameComponent[] name4 = {nc4};\fP
.fi
.nf
\f3 ctx2\&.rebind(name4, objref);\fP
.fi
.nf
\f3 System\&.out\&.println("calender rebind successful!");\fP
.fi
.nf
\f3 } catch (Exception e) {\fP
.fi
.nf
\f3 e\&.printStackTrace(System\&.err);\fP
.fi
.nf
\f3 }\fP
.fi
.nf
\f3 }\fP
.fi
.nf
\f3}\fP
.fi
.nf
\f3\fP
.fi
.sp
.SS BROWSING\ THE\ NAME\ SPACE
The following sample program shoes how to browse the name space\&.
.sp
.nf
\f3import java\&.util\&.Properties;\fP
.fi
.nf
\f3import org\&.omg\&.CORBA\&.*;\fP
.fi
.nf
\f3import org\&.omg\&.CosNaming\&.*;\fP
.fi
.nf
\f3\fP
.fi
.nf
\f3public class NameClientList {\fP
.fi
.nf
\f3\fP
.fi
.nf
\f3 public static void main(String args[]) {\fP
.fi
.nf
\f3\fP
.fi
.nf
\f3 try {\fP
.fi
.nf
\f3\fP
.fi
.sp
In Start the Naming Service, the \f3nameserver\fR was started on port 1050\&. The following code ensures that the client program is aware of this port number\&.
.sp
.nf
\f3 Properties props = new Properties();\fP
.fi
.nf
\f3 props\&.put("org\&.omg\&.CORBA\&.ORBInitialPort", "1050");\fP
.fi
.nf
\f3 ORB orb = ORB\&.init(args, props);\fP
.fi
.nf
\f3\fP
.fi
.sp
The following code obtains the initial naming context\&.
.sp
.nf
\f3 NamingContext nc =\fP
.fi
.nf
\f3 NamingContextHelper\&.narrow(\fP
.fi
.nf
\f3 orb\&.resolve_initial_references("NameService"));\fP
.fi
.nf
\f3\fP
.fi
.sp
The \f3list\fR method lists the bindings in the naming context\&. In this case, up to 1000 bindings from the initial naming context will be returned in the \f3BindingListHolder\fR; any remaining bindings are returned in the \f3BindingIteratorHolder\fR\&.
.sp
.nf
\f3 BindingListHolder bl = new BindingListHolder();\fP
.fi
.nf
\f3 BindingIteratorHolder blIt= new BindingIteratorHolder();\fP
.fi
.nf
\f3 nc\&.list(1000, bl, blIt);\fP
.fi
.nf
\f3\fP
.fi
.sp
This code gets the array of bindings out of the returned \f3BindingListHolder\fR\&. If there are no bindings, then the program ends\&.
.sp
.nf
\f3 Binding bindings[] = bl\&.value;\fP
.fi
.nf
\f3 if (bindings\&.length == 0) return;\fP
.fi
.nf
\f3\fP
.fi
.sp
The remainder of the code loops through the bindings and prints outs the names\&.
.sp
.nf
\f3 for (int i=0; i < bindings\&.length; i++) {\fP
.fi
.nf
\f3\fP
.fi
.nf
\f3 // get the object reference for each binding\fP
.fi
.nf
\f3 org\&.omg\&.CORBA\&.Object obj = nc\&.resolve(bindings[i]\&.binding_name);\fP
.fi
.nf
\f3 String objStr = orb\&.object_to_string(obj);\fP
.fi
.nf
\f3 int lastIx = bindings[i]\&.binding_name\&.length\-1;\fP
.fi
.nf
\f3\fP
.fi
.nf
\f3 // check to see if this is a naming context\fP
.fi
.nf
\f3 if (bindings[i]\&.binding_type == BindingType\&.ncontext) {\fP
.fi
.nf
\f3 System\&.out\&.println("Context: " +\fP
.fi
.nf
\f3 bindings[i]\&.binding_name[lastIx]\&.id);\fP
.fi
.nf
\f3 } else {\fP
.fi
.nf
\f3 System\&.out\&.println("Object: " +\fP
.fi
.nf
\f3 bindings[i]\&.binding_name[lastIx]\&.id);\fP
.fi
.nf
\f3 }\fP
.fi
.nf
\f3 }\fP
.fi
.nf
\f3 } catch (Exception e) {\fP
.fi
.nf
\f3 e\&.printStackTrace(System\&.err)\fP
.fi
.nf
\f3 }\fP
.fi
.nf
\f3 }\fP
.fi
.nf
\f3}\fP
.fi
.nf
\f3\fP
.fi
.sp
.SH SEE\ ALSO
.TP 0.2i
\(bu
orbd(1)
.RE
.br
'pl 8.5i
'bp

View file

@ -1,175 +0,0 @@
'\" t
.\" Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
.\"
.\" This code is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License version 2 only, as
.\" published by the Free Software Foundation.
.\"
.\" This code 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 General Public License
.\" version 2 for more details (a copy is included in the LICENSE file that
.\" accompanied this code).
.\"
.\" You should have received a copy of the GNU General Public License version
.\" 2 along with this work; if not, write to the Free Software Foundation,
.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
.\" or visit www.oracle.com if you need additional information or have any
.\" questions.
.\"
.\" Arch: generic
.\" Software: JDK 8
.\" Date: 21 November 2013
.\" SectDesc: Java Web Services Tools
.\" Title: wsgen.1
.\"
.if n .pl 99999
.TH wsgen 1 "21 November 2013" "JDK 8" "Java Web Services Tools"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH NAME
wsgen \- Reads a web service endpoint implementation (SEI) class and generates all of the required artifacts for web service deployment, and invocation\&.
.SH SYNOPSIS
.sp
.nf
\fBwsgen\fR [ \fIoptions\fR ] \fISEI\fR
.fi
.sp
.TP
\fIoptions\fR
The command-line options\&. See Options\&.
.TP
\fISEI\fR
The web service endpoint implementation class (SEI) to be read\&.
.SH DESCRIPTION
The \f3wsgen\fR command generates JAX-WS portable artifacts used in JAX-WS web services\&. The tool reads a web service endpoint class and generates all the required artifacts for web service deployment and invocation\&. JAXWS 2\&.1\&.1 RI also provides a \f3wsgen\fR Ant task, see the \fITools\fR tab of the JAX-WS (wsgen) page at http://jax-ws\&.java\&.net/nonav/2\&.1\&.1/docs/wsgenant\&.html
.PP
To start the \f3wsgen\fR command, do the following:
.sp
.nf
\f3export JAXWS_HOME=/pathto/jaxws\-ri\fP
.fi
.nf
\f3$JAXWS_HOME/bin/wsgen\&.sh \-help\fP
.fi
.nf
\f3\fP
.fi
.sp
.SH OPTIONS
.TP
-classpath \fIpath\fR
.br
The location of the input class files\&.
.TP
-cp \fIpath\fR
.br
The location of the input class files\&.
.TP
-d \fIdirectory\fR
.br
The location for where to place generated output files\&.
.TP
-extension
.br
Allow vendor extensions\&. Use of extensions can result in applications that are not portable or that do not work with other implementations\&.
.TP
-help
.br
Displays a help message about the \f3wsgen\fR command\&.
.TP
-keep
.br
Keeps the generated files\&.
.TP
-r \fIdirectory\fR
.br
Uses this option with the \f3-wsdl\fR option to specify where to place generated resource files such as WSDLs\&.
.TP
-s \fIdirectory\fR
.br
The location for where to place generated source files\&.
.TP
-verbose
.br
Displays compiler messages\&.
.TP
-version
.br
Prints release information\&.
.TP
-wsdl [ :protocol ] \fI\fR
.br
An optional command that generates a WSDL file to review before endpoint deployment\&. The WSDL files contains a machine-readable description of how the service can be called, what parameters it expects, and what data structures it returns\&.
By default the \f3wsgen\fR command does not generate a WSDL file\&. The \f3protocol\fR value is optional and is used to specify what protocol should be used for the WSDL binding (\f3wsdl:binding\fR)\&. Valid protocols are \f3soap1\&.1\fR and \f3Xsoap1\&.2\fR\&. The default is \f3soap1\&.1\fR\&. The \f3Xsoap1\&.2\fR protocol is not standard and can only be used with the \f3-extension\fR option\&.
.TP
-servicename \fIname\fR
.br
Used only with the \f3-wsdl\fR option to specify a particular WSDL service (\f3wsdl:service\fR) name to be generated in the WSDL, for example: \f3-servicename "{http://mynamespace/}MyService"\fR\&.
.TP
-portname \fIname\fR
.br
Used only with the \f3-wsdl\fR option to specify a particular WSDL port (\f3wsdl:port\fR) name to be generated in the WSDL, for example: \f3-portname "{http://mynamespace/}MyPort"\fR\&.
.SH EXAMPLES
The following example generates the wrapper classes for \f3StockService\fR with \f3@WebService\fR annotations inside stock directory\&.
.sp
.nf
\f3wsgen \-d stock \-cp myclasspath stock\&.StockService\fP
.fi
.nf
\f3\fP
.fi
.sp
The following example generates a SOAP 1\&.1 WSDL and schema for the \f3stock\&.StockService\fR class with \f3@WebService\fR annotations\&.
.sp
.nf
\f3wsgen \-wsdl \-d stock \-cp myclasspath stock\&.StockService\fP
.fi
.nf
\f3\fP
.fi
.sp
The following example generates a SOAP 1\&.2 WSDL\&.
.sp
.nf
\f3wsgen \-wsdl:Xsoap1\&.2 \-d stock \-cp myclasspath stock\&.StockService \fP
.fi
.nf
\f3\fP
.fi
.sp
\fINote:\fR You do not have to generate WSDL at development time because the JAXWS run time environment generates a WSDL for you when you deploy your service\&.
.SH SEE\ ALSO
.TP 0.2i
\(bu
wsimport(1)
.TP 0.2i
\(bu
\fIThe Tools\fR tab of the JAX-WS (wsgen) page http://jax-ws\&.java\&.net/nonav/2\&.1\&.1/docs/wsgenant\&.html
.RE
.br
'pl 8.5i
'bp

View file

@ -1,216 +0,0 @@
'\" t
.\" Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
.\"
.\" This code is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License version 2 only, as
.\" published by the Free Software Foundation.
.\"
.\" This code 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 General Public License
.\" version 2 for more details (a copy is included in the LICENSE file that
.\" accompanied this code).
.\"
.\" You should have received a copy of the GNU General Public License version
.\" 2 along with this work; if not, write to the Free Software Foundation,
.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
.\" or visit www.oracle.com if you need additional information or have any
.\" questions.
.\"
.\" Arch: generic
.\" Software: JDK 8
.\" Date: 21 November 2013
.\" SectDesc: Java Web Services Tools
.\" Title: wsimport.1
.\"
.if n .pl 99999
.TH wsimport 1 "21 November 2013" "JDK 8" "Java Web Services Tools"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH NAME
wsimport \- Generates JAX-WS portable artifacts that can be packaged in a web application archive (WAR) file and provides an Ant task\&.
.SH SYNOPSIS
.sp
.nf
\fBwsimport\fR [ \fIoptions\fR ] \fIwsdl\fR
.fi
.sp
.TP
\fIoptions\fR
The command-line options\&. See Options\&.
.TP
\fIwsdl\fR
The file that contains the machine-readable description of how the web service can be called, what parameters it expects, and what data structures it returns\&.
.SH DESCRIPTION
The \f3wsimport\fR command generates the following JAX-WS portable artifacts\&. These artifacts can be packaged in a WAR file with the WSDL and schema documents and the endpoint implementation to be deployed\&. The \f3wsimport\fR command also provides a \f3wsimport\fR Ant task, see the Tools tab of the Wsimport Ant Task page at http://jax-ws\&.java\&.net/nonav/2\&.1\&.1/docs/wsimportant\&.html
.TP 0.2i
\(bu
Service Endpoint Interface (SEI)
.TP 0.2i
\(bu
Service
.TP 0.2i
\(bu
Exception class is mapped from \f3wsdl:fault\fR (if any)
.TP 0.2i
\(bu
Async Response Bean is derived from response \f3wsdl:message\fR (if any)
.TP 0.2i
\(bu
JAXB generated value types (mapped java classes from schema types)
.PP
To start the \f3wsgen\fR command, do the following:
.PP
\fIOracle Solaris/Linux\fR:
.sp
.nf
\f3/bin/wsimport\&.sh \-help\fP
.fi
.nf
\f3\fP
.fi
.sp
\fIWindows\fR:
.sp
.nf
\f3\ebin\ewsimport\&.bat \-help\fP
.fi
.nf
\f3\fP
.fi
.sp
.SH OPTIONS
.TP
-d \fIdirectory\fR
.br
Specifies where to place generated output files\&.
.TP
-b \fIpath\fR
.br
Specifies external JAX-WS or JAXB binding files\&. Multiple JAX-WS and JAXB binding files can be specified with the \f3-b\fR option\&. You can use these files to customize package names, bean names, and so on\&. For more information about JAX-WS and JAXB binding files, see the \fIUsers Guide\fR tab of WSDL Customization at http://jax-ws\&.java\&.net/nonav/2\&.1\&.1/docs/wsimportant\&.html
.TP
-B \fIjaxbOption\fR
.br
Passes the \f3jaxbOption\fR option to the JAXB schema compiler\&.
.TP
-catalog
.br
Specifies a catalog file to resolve external entity references\&. The \f3-catalog\fR option supports the TR9401, XCatalog, and OASIS XML Catalog formats\&. See the \fIUsers Guide\fR tab of the Catalog Support page at http://jax-ws\&.java\&.net/nonav/2\&.1\&.1/docs/catalog-support\&.html
.TP
-extension
.br
Allows vendor extensions\&. Use of extensions can result in applications that are not portable or that do not work with other implementations\&.
.TP
-help
.br
Displays a help message for the \f3wsimport\fR command\&.
.TP
-httpproxy: \fIhost\fR:\fIport\fR
.br
Specifies an HTTP proxy server\&. The default is 8080\&.
.TP
-keep
.br
Keeps generated files\&.
.TP
-p \fIname\fR
.br
Specifies a target package \fIname\fR to override the WSDL and schema binding customizations, and the default algorithm defined in the specification\&.
.TP
-s \fIdirectory\fR
.br
Specifies where to place generated source files\&.
.TP
-verbose
.br
Displays compiler messages\&.
.TP
-version
.br
Prints release information\&.
.TP
-wsdllocation \fIlocation\fR
.br
Specifies the \f3@WebServiceClient\&.wsdlLocation\fR value\&.
.TP
-target
.br
Generates code according to the specified JAX-WS specification version\&. Version 2\&.0 generates compliant code for the JAX-WS 2\&.0 specification\&.
.TP
-quiet
.br
Suppresses the \f3wsimport\fR command output\&.
.PP
Multiple \f3JAX-WS\fR and \f3JAXB\fR binding files can be specified using the \f3-b\fR option, and they can be used to customize various things such as package names and bean names\&. More information about \f3JAX-WS\fR and \f3JAXB\fR binding files can be found in the customization documentation at https://jax-ws\&.dev\&.java\&.net/nonav/2\&.1\&.1/docs/customizations\&.html
.SH NONSTANDARD\ OPTIONS
.TP
-XadditionalHeaders
.br
Maps headers not bound to a request or response message to Java method parameters\&.
.TP
-Xauthfile \fIfile\fR
.br
The WSDL URI that specifies the file that contains authorization information\&. This URI is in the following format:
http://\fIuser-name\fR:\f3password\fR@\fIhost-name\fR/\fIweb-service-name\fR>?wsdl\&.
.TP
-Xdebug
.br
Prints debugging information\&.
.TP
-Xno-addressing-databinding
.br
Enables binding of W3C EndpointReferenceType to Java\&.
.TP
-Xnocompile
.br
Does not compile the generated Java files\&.
.SH EXAMPLE
The following example generates the Java artifacts and compiles the artifacts by importing \f3http://stockquote\&.example\&.com/quote?wsdl\fR
.sp
.nf
\f3wsimport \-p stockquote http://stockquote\&.example\&.com/quote?wsdl\fP
.fi
.nf
\f3\fP
.fi
.sp
.SH SEE\ ALSO
.TP 0.2i
\(bu
wsgen(1)
.TP 0.2i
\(bu
The Tools tab of Wsimport Ant Task page http://jax-ws\&.java\&.net/nonav/2\&.1\&.1/docs/wsimportant\&.html
.TP 0.2i
\(bu
The \fIUsers Guide\fR tab of Catalog Support page http://jax-ws\&.java\&.net/nonav/2\&.1\&.1/docs/catalog-support\&.html
.TP 0.2i
\(bu
The \fIUsers Guide\fR tab of WSDL Customization page http://jax-ws\&.java\&.net/nonav/2\&.1\&.1/docs/wsimportant\&.html
.RE
.br
'pl 8.5i
'bp

View file

@ -1,232 +0,0 @@
'\" t
.\" Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
.\"
.\" This code is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License version 2 only, as
.\" published by the Free Software Foundation.
.\"
.\" This code 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 General Public License
.\" version 2 for more details (a copy is included in the LICENSE file that
.\" accompanied this code).
.\"
.\" You should have received a copy of the GNU General Public License version
.\" 2 along with this work; if not, write to the Free Software Foundation,
.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
.\" or visit www.oracle.com if you need additional information or have any
.\" questions.
.\"
.\" Arch: generic
.\" Software: JDK 8
.\" Date: 21 November 2013
.\" SectDesc: Java Web Services Tools
.\" Title: xjc.1
.\"
.if n .pl 99999
.TH xjc 1 "21 November 2013" "JDK 8" "Java Web Services Tools"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH NAME
xjc \- Compiles an XML schema file into fully annotated Java classes\&.
.SH SYNOPSIS
.sp
.nf
\fBxjc\fR [ \fIoptions\fR ] \fBschema\fR \fIfile/URL/dir/jar\fR \&.\&.\&. [\fB\-b\fR \fIbindinfo\fR ] \&.\&.\&.
.fi
.sp
.TP
\fIoptions\fR
The command-line options\&. See Options\&.
.TP
schema \fIfile/URL/dir/jar \&.\&.\&.\fR
The location of the XML schema file\&. If \f3dir\fR is specified, then all schema files in it are compiled\&. If \f3jar\fR is specified, then the \f3/META-INF/sun-jaxb\&.episode\fR binding file is compiled\&.
.TP
-b \fIbindinfo\fR
.br
The location of the bindings files\&.
.SH DESCRIPTION
Start the binding compiler with the appropriate \f3xjc\fR shell script in the bin directory for your platform\&. There is also an Ant task to run the binding complier\&. See Using the XJC with Ant at http://jaxb\&.java\&.net/nonav/2\&.1\&.3/docs/xjcTask\&.html
.SH OPTIONS
.TP 0.2i
\(bu
See also Nonstandard Options
.TP 0.2i
\(bu
See also Deprecated and Removed Options
.TP
-nv
.br
By default, the XJC binding compiler performs strict validation of the source schema before processing it\&. Use this option to disable strict schema validation\&. This does not mean that the binding compiler will not perform any validation, but means that it will perform a less-strict validation\&.
.TP
-extension
.br
By default, the XJC binding compiler strictly enforces the rules outlined in the Compatibility chapter of the JAXB Specification\&. Appendix E\&.2 defines a set of W3C XML Schema features that are not completely supported by JAXB v1\&.0\&. In some cases, you may be allowed to use them in the \f3-extension\fR mode enabled by this switch\&. In the default (strict) mode, you are also limited to using only the binding customization defined in the specification\&. By using the \f3-extension\fR switch, you will be allowed to use the JAXB Vendor Extensions\&.
.TP
-b \fIfile\fR
.br
Specifies one or more external binding files to process\&. Each binding file must have its own \f3-b\fR switch\&. The syntax of the external binding files is flexible\&. You can have a single binding file that contains customization for multiple schemas or you can break the customization into multiple bindings files: \f3xjc schema1\&.xsd schema2\&.xsd schema3\&.xsd -b bindings123\&.xjb\fR\f3xjc schema1\&.xsd schema2\&.xsd schema3\&.xsd -b bindings1\&.xjb -b bindings2\&.xjb -b bindings3\&.xjb\fR\&. In addition, the ordering of the schema files and binding files on the command line does not matter\&.
.TP
-d \fIdir\fR
.br
By default, the XJC binding compiler generates the Java content classes in the current directory\&. Use this option to specify an alternate output directory\&. The output directory must already exist\&. The XJC binding compiler does not create it for you\&.
.TP
-p \fIpkg\fR
.br
When you specify a target package with this command-line option, it overrides any binding customization for the package name and the default package name algorithm defined in the specification\&.
.TP
-httpproxy \fIproxy\fR
.br
Specifies the HTTP or HTTPS proxy in the format \fI[user[:password]@]proxyHost[:proxyPort]\fR\&. The old \f3-host\fR and \f3-port\fR options are still supported by the RI for backward compatibility, but they were deprecated\&. The password specified with this option is an argument that is visible to other users who use the top command\&. For greater security, use the \f3-httpproxyfile\fR option\&.
.TP
-httpproxyfile file
.br
Specifies the HTTP or HTTPS proxy with a file\&. The same format as the \f3-httpproxy\fR option, but the password specified in the file is not visible to other users\&.
.TP
-classpath arg
.br
Specifies where to find client application class files used by the \fIjxb:javaType\fR and xjc:\fIsuperClass\fR customization\&.
.TP
-catalog file
.br
Specifies catalog files to resolve external entity references\&. Supports the TR9401, XCatalog, and OASIS XML Catalog formats\&. See XML Entity and URI Resolvers at http://xerces\&.apache\&.org/xml-commons/components/resolver/resolver-article\&.html
.TP
-readOnly
.br
By default, the XJC binding compiler does not write-protect the Java source files it generates\&. Use this option to force the XJC binding compiler to mark the generated Java sources as read-only\&.
.TP
-npa
.br
Suppresses the generation of package level annotations into \f3**/package-info\&.java\fR\&. Using this switch causes the generated code to internalize those annotations into the other generated classes\&.
.TP
-no-header
.br
Suppresses the generation of a file header comment that includes some note and time stamp\&. Using this makes the generated code more compatible with the \f3diff\fR command\&.
.TP
-target 2\&.0
.br
Avoids generating code that relies on any JAXB 2\&.1 features\&. This will allow the generated code to run with JAXB 2\&.0 runtime environment (such as Java SE 6)\&.
.TP
-xmlschema
.br
Treats input schemas as W3C XML Schema (default)\&. If you do not specify this switch, then your input schemas are treated as though they are W3C XML Schemas\&.
.TP
-relaxing
.br
Treats input schemas as RELAX NG (experimental and unsupported)\&. Support for RELAX NG schemas is provided as a JAXB Vendor Extension\&.
.TP
-relaxing-compact
.br
Treat input schemas as RELAX NG compact syntax (experimental and unsupported)\&. Support for RELAX NG schemas is provided as a JAXB Vendor Extension\&.
.TP
-dtd
.br
Treats input schemas as XML DTD (experimental and unsupported)\&. Support for RELAX NG schemas is provided as a JAXB Vendor Extension\&.
.TP
-wsdl
.br
Treats input as WSDL and compiles schemas inside it (experimental and unsupported)\&.
.TP
-quiet
.br
Suppress compiler output, such as progress information and warnings\&.
.TP
-verbose
.br
Be extra verbose, such as printing informational messages or displaying stack traces upon some errors\&.
.TP
-help
.br
Displays a brief summary of the compiler switches\&.
.TP
-version
.br
Displays the compiler version information\&.
.TP
\fIschema file/URL/dir\fR
Specifies one or more schema files to compile\&. If you specify a directory, then the \f3xjc\fR command scans it for all schema files and compiles them\&.
.SS NONSTANDARD\ OPTIONS
.TP
-XLocator
.br
Causes the generated code to expose SAX Locator information about the source XML in the Java bean instances after unmarshalling\&.
.TP
-Xsync-methods
.br
Causes all of the generated method signatures to include the \f3synchronized\fR keyword\&.
.TP
-mark-generated
.br
Marks the generated code with the annotation \f3@javax\&.annotation\&.Generated\fR\&.
.TP
-episode file
.br
Generates the specified episode file for separate compilation\&.
.SS DEPRECATED\ AND\ REMOVED\ OPTIONS
.TP
-host & -port
.br
These options are replaced with the \f3-httpproxy\fR option\&. For backward compatibility, these options are supported, but will not be documented and might be removed from future releases\&.
.TP
-use-runtime
.br
Because the JAXB 2\&.0 specification has defined a portable runtime environment, it is no longer necessary for the JAXB RI to generate \f3**/impl/runtime\fRpackages\&. Therefore, this switch is obsolete and was removed\&.
.TP
-source
.br
The \f3-source\fR compatibility switch was introduced in the first JAXB 2\&.0 Early Access release\&. This switch is removed from future releases of JAXB 2\&.0\&. If you need to generate 1\&.0\&.x code, then use an installation of the 1\&.0\&.x code base\&.
.SH COMPILER\ RESTRICTIONS
In general, it is safest to compile all related schemas as a single unit with the same binding compiler switches\&. Keep the following list of restrictions in mind when running the \f3xjc\fR command\&. Most of these issues only apply when you compile multiple schemas with multiple invocations of the \f3xjc\fR command\&.
.PP
To compile multiple schemas at the same time, keep the following precedence rules for the target Java package name in mind:
.TP 0.4i
1\&.
The \f3-p\fR option has the highest precedence\&.
.TP 0.4i
2\&.
\fIjaxb:package\fR customization\&.
.TP 0.4i
3\&.
If \f3targetNamespace\fR is declared, then apply the \f3t\fR\f3argetNamespace\fR to the Java package name algorithm defined in the specification\&.
.TP 0.4i
4\&.
If no \f3targetNamespace\fR is declared, then use a hard coded package named \f3generated\fR\&.
.PP
You cannot have more than one \fIjaxb:schemaBindings\fR per name space, so it is impossible to have two schemas in the same target name space compiled into different Java packages\&.
.PP
All schemas being compiled into the same Java package must be submitted to the XJC binding compiler at the same time\&. They cannot be compiled independently and work as expected\&.
.PP
Element substitution groups that are spread across multiple schema files must be compiled at the same time\&.
.SH SEE\ ALSO
.TP 0.2i
\(bu
Binding Compiler (xjc) at http://jaxb\&.java\&.net/nonav/2\&.2\&.3u1/docs/xjc\&.html
.TP 0.2i
\(bu
Java Architecture for XML Binding (JAXB) at http://www\&.oracle\&.com/technetwork/articles/javase/index-140168\&.html
.RE
.br
'pl 8.5i
'bp

View file

@ -1,7 +0,0 @@
#
# This is a very simple 'mailcap' file
#
image/gif;; x-java-view=com.sun.activation.viewers.ImageViewer
image/jpeg;; x-java-view=com.sun.activation.viewers.ImageViewer
text/*;; x-java-view=com.sun.activation.viewers.TextViewer
text/*;; x-java-edit=com.sun.activation.viewers.TextEditor

View file

@ -1,25 +0,0 @@
#
# A simple, old format, mime.types file
#
text/html html htm HTML HTM
text/plain txt text TXT TEXT
image/gif gif GIF
image/ief ief
image/jpeg jpeg jpg jpe JPG
image/tiff tiff tif
image/png png PNG
image/x-xwindowdump xwd
application/postscript ai eps ps
application/rtf rtf
application/x-tex tex
application/x-texinfo texinfo texi
application/x-troff t tr roff
audio/basic au
audio/midi midi mid
audio/x-aifc aifc
audio/x-aiff aif aiff
audio/x-mpeg mpeg mpg
audio/x-wav wav
video/mpeg mpeg mpg mpe
video/quicktime qt mov
video/x-msvideo avi

View file

@ -1,70 +0,0 @@
/*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.activation.registries;
import java.io.*;
import java.util.logging.*;
/**
* Logging related methods.
*/
public class LogSupport {
private static boolean debug = false;
private static Logger logger;
private static final Level level = Level.FINE;
static {
try {
debug = Boolean.getBoolean("javax.activation.debug");
} catch (Throwable t) {
// ignore any errors
}
logger = Logger.getLogger("javax.activation");
}
/**
* Constructor.
*/
private LogSupport() {
// private constructor, can't create instances
}
public static void log(String msg) {
if (debug)
System.out.println(msg);
logger.log(level, msg);
}
public static void log(String msg, Throwable t) {
if (debug)
System.out.println(msg + "; Exception: " + t);
logger.log(level, msg, t);
}
public static boolean isLoggable() {
return debug || logger.isLoggable(level);
}
}

View file

@ -1,563 +0,0 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.activation.registries;
import java.io.*;
import java.util.*;
public class MailcapFile {
/**
* A Map indexed by MIME type (string) that references
* a Map of commands for each type. The comand Map
* is indexed by the command name and references a List of
* class names (strings) for each command.
*/
private Map type_hash = new HashMap();
/**
* Another Map like above, but for fallback entries.
*/
private Map fallback_hash = new HashMap();
/**
* A Map indexed by MIME type (string) that references
* a List of native commands (string) corresponding to the type.
*/
private Map native_commands = new HashMap();
private static boolean addReverse = false;
static {
try {
addReverse = Boolean.getBoolean("javax.activation.addreverse");
} catch (Throwable t) {
// ignore any errors
}
}
/**
* The constructor that takes a filename as an argument.
*
* @param new_fname The file name of the mailcap file.
*/
public MailcapFile(String new_fname) throws IOException {
if (LogSupport.isLoggable())
LogSupport.log("new MailcapFile: file " + new_fname);
FileReader reader = null;
try {
reader = new FileReader(new_fname);
parse(new BufferedReader(reader));
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ex) { }
}
}
}
/**
* The constructor that takes an input stream as an argument.
*
* @param is the input stream
*/
public MailcapFile(InputStream is) throws IOException {
if (LogSupport.isLoggable())
LogSupport.log("new MailcapFile: InputStream");
parse(new BufferedReader(new InputStreamReader(is, "iso-8859-1")));
}
/**
* Mailcap file default constructor.
*/
public MailcapFile() {
if (LogSupport.isLoggable())
LogSupport.log("new MailcapFile: default");
}
/**
* Get the Map of MailcapEntries based on the MIME type.
*
* <p>
* <strong>Semantics:</strong> First check for the literal mime type,
* if that fails looks for wildcard <type>/\* and return that. Return the
* list of all that hit.
*/
public Map getMailcapList(String mime_type) {
Map search_result = null;
Map wildcard_result = null;
// first try the literal
search_result = (Map)type_hash.get(mime_type);
// ok, now try the wildcard
int separator = mime_type.indexOf('/');
String subtype = mime_type.substring(separator + 1);
if (!subtype.equals("*")) {
String type = mime_type.substring(0, separator + 1) + "*";
wildcard_result = (Map)type_hash.get(type);
if (wildcard_result != null) { // damn, we have to merge!!!
if (search_result != null)
search_result =
mergeResults(search_result, wildcard_result);
else
search_result = wildcard_result;
}
}
return search_result;
}
/**
* Get the Map of fallback MailcapEntries based on the MIME type.
*
* <p>
* <strong>Semantics:</strong> First check for the literal mime type,
* if that fails looks for wildcard <type>/\* and return that. Return the
* list of all that hit.
*/
public Map getMailcapFallbackList(String mime_type) {
Map search_result = null;
Map wildcard_result = null;
// first try the literal
search_result = (Map)fallback_hash.get(mime_type);
// ok, now try the wildcard
int separator = mime_type.indexOf('/');
String subtype = mime_type.substring(separator + 1);
if (!subtype.equals("*")) {
String type = mime_type.substring(0, separator + 1) + "*";
wildcard_result = (Map)fallback_hash.get(type);
if (wildcard_result != null) { // damn, we have to merge!!!
if (search_result != null)
search_result =
mergeResults(search_result, wildcard_result);
else
search_result = wildcard_result;
}
}
return search_result;
}
/**
* Return all the MIME types known to this mailcap file.
*/
public String[] getMimeTypes() {
Set types = new HashSet(type_hash.keySet());
types.addAll(fallback_hash.keySet());
types.addAll(native_commands.keySet());
String[] mts = new String[types.size()];
mts = (String[])types.toArray(mts);
return mts;
}
/**
* Return all the native comands for the given MIME type.
*/
public String[] getNativeCommands(String mime_type) {
String[] cmds = null;
List v =
(List)native_commands.get(mime_type.toLowerCase(Locale.ENGLISH));
if (v != null) {
cmds = new String[v.size()];
cmds = (String[])v.toArray(cmds);
}
return cmds;
}
/**
* Merge the first hash into the second.
* This merge will only effect the hashtable that is
* returned, we don't want to touch the one passed in since
* its integrity must be maintained.
*/
private Map mergeResults(Map first, Map second) {
Iterator verb_enum = second.keySet().iterator();
Map clonedHash = new HashMap(first);
// iterate through the verbs in the second map
while (verb_enum.hasNext()) {
String verb = (String)verb_enum.next();
List cmdVector = (List)clonedHash.get(verb);
if (cmdVector == null) {
clonedHash.put(verb, second.get(verb));
} else {
// merge the two
List oldV = (List)second.get(verb);
cmdVector = new ArrayList(cmdVector);
cmdVector.addAll(oldV);
clonedHash.put(verb, cmdVector);
}
}
return clonedHash;
}
/**
* appendToMailcap: Append to this Mailcap DB, use the mailcap
* format:
* Comment == "# <i>comment string</i>
* Entry == "mimetype; javabeanclass<nl>
*
* Example:
* # this is a comment
* image/gif jaf.viewers.ImageViewer
*/
public void appendToMailcap(String mail_cap) {
if (LogSupport.isLoggable())
LogSupport.log("appendToMailcap: " + mail_cap);
try {
parse(new StringReader(mail_cap));
} catch (IOException ex) {
// can't happen
}
}
/**
* parse file into a hash table of MC Type Entry Obj
*/
private void parse(Reader reader) throws IOException {
BufferedReader buf_reader = new BufferedReader(reader);
String line = null;
String continued = null;
while ((line = buf_reader.readLine()) != null) {
// LogSupport.log("parsing line: " + line);
line = line.trim();
try {
if (line.charAt(0) == '#')
continue;
if (line.charAt(line.length() - 1) == '\\') {
if (continued != null)
continued += line.substring(0, line.length() - 1);
else
continued = line.substring(0, line.length() - 1);
} else if (continued != null) {
// handle the two strings
continued = continued + line;
// LogSupport.log("parse: " + continued);
try {
parseLine(continued);
} catch (MailcapParseException e) {
//e.printStackTrace();
}
continued = null;
}
else {
// LogSupport.log("parse: " + line);
try {
parseLine(line);
// LogSupport.log("hash.size = " + type_hash.size());
} catch (MailcapParseException e) {
//e.printStackTrace();
}
}
} catch (StringIndexOutOfBoundsException e) {}
}
}
/**
* A routine to parse individual entries in a Mailcap file.
*
* Note that this routine does not handle line continuations.
* They should have been handled prior to calling this routine.
*/
protected void parseLine(String mailcapEntry)
throws MailcapParseException, IOException {
MailcapTokenizer tokenizer = new MailcapTokenizer(mailcapEntry);
tokenizer.setIsAutoquoting(false);
if (LogSupport.isLoggable())
LogSupport.log("parse: " + mailcapEntry);
// parse the primary type
int currentToken = tokenizer.nextToken();
if (currentToken != MailcapTokenizer.STRING_TOKEN) {
reportParseError(MailcapTokenizer.STRING_TOKEN, currentToken,
tokenizer.getCurrentTokenValue());
}
String primaryType =
tokenizer.getCurrentTokenValue().toLowerCase(Locale.ENGLISH);
String subType = "*";
// parse the '/' between primary and sub
// if it's not present that's ok, we just don't have a subtype
currentToken = tokenizer.nextToken();
if ((currentToken != MailcapTokenizer.SLASH_TOKEN) &&
(currentToken != MailcapTokenizer.SEMICOLON_TOKEN)) {
reportParseError(MailcapTokenizer.SLASH_TOKEN,
MailcapTokenizer.SEMICOLON_TOKEN, currentToken,
tokenizer.getCurrentTokenValue());
}
// only need to look for a sub type if we got a '/'
if (currentToken == MailcapTokenizer.SLASH_TOKEN) {
// parse the sub type
currentToken = tokenizer.nextToken();
if (currentToken != MailcapTokenizer.STRING_TOKEN) {
reportParseError(MailcapTokenizer.STRING_TOKEN,
currentToken, tokenizer.getCurrentTokenValue());
}
subType =
tokenizer.getCurrentTokenValue().toLowerCase(Locale.ENGLISH);
// get the next token to simplify the next step
currentToken = tokenizer.nextToken();
}
String mimeType = primaryType + "/" + subType;
if (LogSupport.isLoggable())
LogSupport.log(" Type: " + mimeType);
// now setup the commands hashtable
Map commands = new LinkedHashMap(); // keep commands in order found
// parse the ';' that separates the type from the parameters
if (currentToken != MailcapTokenizer.SEMICOLON_TOKEN) {
reportParseError(MailcapTokenizer.SEMICOLON_TOKEN,
currentToken, tokenizer.getCurrentTokenValue());
}
// eat it
// parse the required view command
tokenizer.setIsAutoquoting(true);
currentToken = tokenizer.nextToken();
tokenizer.setIsAutoquoting(false);
if ((currentToken != MailcapTokenizer.STRING_TOKEN) &&
(currentToken != MailcapTokenizer.SEMICOLON_TOKEN)) {
reportParseError(MailcapTokenizer.STRING_TOKEN,
MailcapTokenizer.SEMICOLON_TOKEN, currentToken,
tokenizer.getCurrentTokenValue());
}
if (currentToken == MailcapTokenizer.STRING_TOKEN) {
// have a native comand, save the entire mailcap entry
//String nativeCommand = tokenizer.getCurrentTokenValue();
List v = (List)native_commands.get(mimeType);
if (v == null) {
v = new ArrayList();
v.add(mailcapEntry);
native_commands.put(mimeType, v);
} else {
// XXX - check for duplicates?
v.add(mailcapEntry);
}
}
// only have to get the next token if the current one isn't a ';'
if (currentToken != MailcapTokenizer.SEMICOLON_TOKEN) {
currentToken = tokenizer.nextToken();
}
// look for a ';' which will indicate whether
// a parameter list is present or not
if (currentToken == MailcapTokenizer.SEMICOLON_TOKEN) {
boolean isFallback = false;
do {
// eat the ';'
// parse the parameter name
currentToken = tokenizer.nextToken();
if (currentToken != MailcapTokenizer.STRING_TOKEN) {
reportParseError(MailcapTokenizer.STRING_TOKEN,
currentToken, tokenizer.getCurrentTokenValue());
}
String paramName = tokenizer.getCurrentTokenValue().
toLowerCase(Locale.ENGLISH);
// parse the '=' which separates the name from the value
currentToken = tokenizer.nextToken();
if ((currentToken != MailcapTokenizer.EQUALS_TOKEN) &&
(currentToken != MailcapTokenizer.SEMICOLON_TOKEN) &&
(currentToken != MailcapTokenizer.EOI_TOKEN)) {
reportParseError(MailcapTokenizer.EQUALS_TOKEN,
MailcapTokenizer.SEMICOLON_TOKEN,
MailcapTokenizer.EOI_TOKEN,
currentToken, tokenizer.getCurrentTokenValue());
}
// we only have a useful command if it is named
if (currentToken == MailcapTokenizer.EQUALS_TOKEN) {
// eat it
// parse the parameter value (which is autoquoted)
tokenizer.setIsAutoquoting(true);
currentToken = tokenizer.nextToken();
tokenizer.setIsAutoquoting(false);
if (currentToken != MailcapTokenizer.STRING_TOKEN) {
reportParseError(MailcapTokenizer.STRING_TOKEN,
currentToken, tokenizer.getCurrentTokenValue());
}
String paramValue =
tokenizer.getCurrentTokenValue();
// add the class to the list iff it is one we care about
if (paramName.startsWith("x-java-")) {
String commandName = paramName.substring(7);
// 7 == "x-java-".length
if (commandName.equals("fallback-entry") &&
paramValue.equalsIgnoreCase("true")) {
isFallback = true;
} else {
// setup the class entry list
if (LogSupport.isLoggable())
LogSupport.log(" Command: " + commandName +
", Class: " + paramValue);
List classes = (List)commands.get(commandName);
if (classes == null) {
classes = new ArrayList();
commands.put(commandName, classes);
}
if (addReverse)
classes.add(0, paramValue);
else
classes.add(paramValue);
}
}
// set up the next iteration
currentToken = tokenizer.nextToken();
}
} while (currentToken == MailcapTokenizer.SEMICOLON_TOKEN);
Map masterHash = isFallback ? fallback_hash : type_hash;
Map curcommands =
(Map)masterHash.get(mimeType);
if (curcommands == null) {
masterHash.put(mimeType, commands);
} else {
if (LogSupport.isLoggable())
LogSupport.log("Merging commands for type " + mimeType);
// have to merge current and new commands
// first, merge list of classes for commands already known
Iterator cn = curcommands.keySet().iterator();
while (cn.hasNext()) {
String cmdName = (String)cn.next();
List ccv = (List)curcommands.get(cmdName);
List cv = (List)commands.get(cmdName);
if (cv == null)
continue;
// add everything in cv to ccv, if it's not already there
Iterator cvn = cv.iterator();
while (cvn.hasNext()) {
String clazz = (String)cvn.next();
if (!ccv.contains(clazz))
if (addReverse)
ccv.add(0, clazz);
else
ccv.add(clazz);
}
}
// now, add commands not previously known
cn = commands.keySet().iterator();
while (cn.hasNext()) {
String cmdName = (String)cn.next();
if (curcommands.containsKey(cmdName))
continue;
List cv = (List)commands.get(cmdName);
curcommands.put(cmdName, cv);
}
}
} else if (currentToken != MailcapTokenizer.EOI_TOKEN) {
reportParseError(MailcapTokenizer.EOI_TOKEN,
MailcapTokenizer.SEMICOLON_TOKEN,
currentToken, tokenizer.getCurrentTokenValue());
}
}
protected static void reportParseError(int expectedToken, int actualToken,
String actualTokenValue) throws MailcapParseException {
throw new MailcapParseException("Encountered a " +
MailcapTokenizer.nameForToken(actualToken) + " token (" +
actualTokenValue + ") while expecting a " +
MailcapTokenizer.nameForToken(expectedToken) + " token.");
}
protected static void reportParseError(int expectedToken,
int otherExpectedToken, int actualToken, String actualTokenValue)
throws MailcapParseException {
throw new MailcapParseException("Encountered a " +
MailcapTokenizer.nameForToken(actualToken) + " token (" +
actualTokenValue + ") while expecting a " +
MailcapTokenizer.nameForToken(expectedToken) + " or a " +
MailcapTokenizer.nameForToken(otherExpectedToken) + " token.");
}
protected static void reportParseError(int expectedToken,
int otherExpectedToken, int anotherExpectedToken, int actualToken,
String actualTokenValue) throws MailcapParseException {
if (LogSupport.isLoggable())
LogSupport.log("PARSE ERROR: " + "Encountered a " +
MailcapTokenizer.nameForToken(actualToken) + " token (" +
actualTokenValue + ") while expecting a " +
MailcapTokenizer.nameForToken(expectedToken) + ", a " +
MailcapTokenizer.nameForToken(otherExpectedToken) + ", or a " +
MailcapTokenizer.nameForToken(anotherExpectedToken) + " token.");
throw new MailcapParseException("Encountered a " +
MailcapTokenizer.nameForToken(actualToken) + " token (" +
actualTokenValue + ") while expecting a " +
MailcapTokenizer.nameForToken(expectedToken) + ", a " +
MailcapTokenizer.nameForToken(otherExpectedToken) + ", or a " +
MailcapTokenizer.nameForToken(anotherExpectedToken) + " token.");
}
/** for debugging
public static void main(String[] args) throws Exception {
Map masterHash = new HashMap();
for (int i = 0; i < args.length; ++i) {
System.out.println("Entry " + i + ": " + args[i]);
parseLine(args[i], masterHash);
}
Enumeration types = masterHash.keys();
while (types.hasMoreElements()) {
String key = (String)types.nextElement();
System.out.println("MIME Type: " + key);
Map commandHash = (Map)masterHash.get(key);
Enumeration commands = commandHash.keys();
while (commands.hasMoreElements()) {
String command = (String)commands.nextElement();
System.out.println(" Command: " + command);
Vector classes = (Vector)commandHash.get(command);
for (int i = 0; i < classes.size(); ++i) {
System.out.println(" Class: " +
(String)classes.elementAt(i));
}
}
System.out.println("");
}
}
*/
}

View file

@ -1,40 +0,0 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.activation.registries;
/**
* A class to encapsulate Mailcap parsing related exceptions
*/
public class MailcapParseException extends Exception {
public MailcapParseException() {
super();
}
public MailcapParseException(String inInfo) {
super(inInfo);
}
}

View file

@ -1,321 +0,0 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.activation.registries;
/**
* A tokenizer for strings in the form of "foo/bar; prop1=val1; ... ".
* Useful for parsing MIME content types.
*/
public class MailcapTokenizer {
public static final int UNKNOWN_TOKEN = 0;
public static final int START_TOKEN = 1;
public static final int STRING_TOKEN = 2;
public static final int EOI_TOKEN = 5;
public static final int SLASH_TOKEN = '/';
public static final int SEMICOLON_TOKEN = ';';
public static final int EQUALS_TOKEN = '=';
/**
* Constructor
*
* @param inputString the string to tokenize
*/
public MailcapTokenizer(String inputString) {
data = inputString;
dataIndex = 0;
dataLength = inputString.length();
currentToken = START_TOKEN;
currentTokenValue = "";
isAutoquoting = false;
autoquoteChar = ';';
}
/**
* Set whether auto-quoting is on or off.
*
* Auto-quoting means that all characters after the first
* non-whitespace, non-control character up to the auto-quote
* terminator character or EOI (minus any whitespace immediatley
* preceeding it) is considered a token.
*
* This is required for handling command strings in a mailcap entry.
*/
public void setIsAutoquoting(boolean value) {
isAutoquoting = value;
}
/**
* Retrieve current token.
*
* @return The current token value
*/
public int getCurrentToken() {
return currentToken;
}
/*
* Get a String that describes the given token.
*/
public static String nameForToken(int token) {
String name = "really unknown";
switch(token) {
case UNKNOWN_TOKEN:
name = "unknown";
break;
case START_TOKEN:
name = "start";
break;
case STRING_TOKEN:
name = "string";
break;
case EOI_TOKEN:
name = "EOI";
break;
case SLASH_TOKEN:
name = "'/'";
break;
case SEMICOLON_TOKEN:
name = "';'";
break;
case EQUALS_TOKEN:
name = "'='";
break;
}
return name;
}
/*
* Retrieve current token value.
*
* @return A String containing the current token value
*/
public String getCurrentTokenValue() {
return currentTokenValue;
}
/*
* Process the next token.
*
* @return the next token
*/
public int nextToken() {
if (dataIndex < dataLength) {
// skip white space
while ((dataIndex < dataLength) &&
(isWhiteSpaceChar(data.charAt(dataIndex)))) {
++dataIndex;
}
if (dataIndex < dataLength) {
// examine the current character and see what kind of token we have
char c = data.charAt(dataIndex);
if (isAutoquoting) {
if (c == ';' || c == '=') {
currentToken = c;
currentTokenValue = new Character(c).toString();
++dataIndex;
} else {
processAutoquoteToken();
}
} else {
if (isStringTokenChar(c)) {
processStringToken();
} else if ((c == '/') || (c == ';') || (c == '=')) {
currentToken = c;
currentTokenValue = new Character(c).toString();
++dataIndex;
} else {
currentToken = UNKNOWN_TOKEN;
currentTokenValue = new Character(c).toString();
++dataIndex;
}
}
} else {
currentToken = EOI_TOKEN;
currentTokenValue = null;
}
} else {
currentToken = EOI_TOKEN;
currentTokenValue = null;
}
return currentToken;
}
private void processStringToken() {
// capture the initial index
int initialIndex = dataIndex;
// skip to 1st non string token character
while ((dataIndex < dataLength) &&
isStringTokenChar(data.charAt(dataIndex))) {
++dataIndex;
}
currentToken = STRING_TOKEN;
currentTokenValue = data.substring(initialIndex, dataIndex);
}
private void processAutoquoteToken() {
// capture the initial index
int initialIndex = dataIndex;
// now skip to the 1st non-escaped autoquote termination character
// XXX - doesn't actually consider escaping
boolean foundTerminator = false;
while ((dataIndex < dataLength) && !foundTerminator) {
char c = data.charAt(dataIndex);
if (c != autoquoteChar) {
++dataIndex;
} else {
foundTerminator = true;
}
}
currentToken = STRING_TOKEN;
currentTokenValue =
fixEscapeSequences(data.substring(initialIndex, dataIndex));
}
private static boolean isSpecialChar(char c) {
boolean lAnswer = false;
switch(c) {
case '(':
case ')':
case '<':
case '>':
case '@':
case ',':
case ';':
case ':':
case '\\':
case '"':
case '/':
case '[':
case ']':
case '?':
case '=':
lAnswer = true;
break;
}
return lAnswer;
}
private static boolean isControlChar(char c) {
return Character.isISOControl(c);
}
private static boolean isWhiteSpaceChar(char c) {
return Character.isWhitespace(c);
}
private static boolean isStringTokenChar(char c) {
return !isSpecialChar(c) && !isControlChar(c) && !isWhiteSpaceChar(c);
}
private static String fixEscapeSequences(String inputString) {
int inputLength = inputString.length();
StringBuffer buffer = new StringBuffer();
buffer.ensureCapacity(inputLength);
for (int i = 0; i < inputLength; ++i) {
char currentChar = inputString.charAt(i);
if (currentChar != '\\') {
buffer.append(currentChar);
} else {
if (i < inputLength - 1) {
char nextChar = inputString.charAt(i + 1);
buffer.append(nextChar);
// force a skip over the next character too
++i;
} else {
buffer.append(currentChar);
}
}
}
return buffer.toString();
}
private String data;
private int dataIndex;
private int dataLength;
private int currentToken;
private String currentTokenValue;
private boolean isAutoquoting;
private char autoquoteChar;
/*
public static void main(String[] args) {
for (int i = 0; i < args.length; ++i) {
MailcapTokenizer tokenizer = new MailcapTokenizer(args[i]);
System.out.println("Original: |" + args[i] + "|");
int currentToken = tokenizer.nextToken();
while (currentToken != EOI_TOKEN) {
switch(currentToken) {
case UNKNOWN_TOKEN:
System.out.println(" Unknown Token: |" + tokenizer.getCurrentTokenValue() + "|");
break;
case START_TOKEN:
System.out.println(" Start Token: |" + tokenizer.getCurrentTokenValue() + "|");
break;
case STRING_TOKEN:
System.out.println(" String Token: |" + tokenizer.getCurrentTokenValue() + "|");
break;
case EOI_TOKEN:
System.out.println(" EOI Token: |" + tokenizer.getCurrentTokenValue() + "|");
break;
case SLASH_TOKEN:
System.out.println(" Slash Token: |" + tokenizer.getCurrentTokenValue() + "|");
break;
case SEMICOLON_TOKEN:
System.out.println(" Semicolon Token: |" + tokenizer.getCurrentTokenValue() + "|");
break;
case EQUALS_TOKEN:
System.out.println(" Equals Token: |" + tokenizer.getCurrentTokenValue() + "|");
break;
default:
System.out.println(" Really Unknown Token: |" + tokenizer.getCurrentTokenValue() + "|");
break;
}
currentToken = tokenizer.nextToken();
}
System.out.println("");
}
}
*/
}

View file

@ -1,50 +0,0 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.activation.registries;
import java.lang.*;
public class MimeTypeEntry {
private String type;
private String extension;
public MimeTypeEntry(String mime_type, String file_ext) {
type = mime_type;
extension = file_ext;
}
public String getMIMEType() {
return type;
}
public String getFileExtension() {
return extension;
}
public String toString() {
return "MIMETypeEntry: " + type + ", " + extension;
}
}

View file

@ -1,317 +0,0 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.activation.registries;
import java.io.*;
import java.util.*;
public class MimeTypeFile {
private String fname = null;
private Hashtable type_hash = new Hashtable();
/**
* The construtor that takes a filename as an argument.
*
* @param new_fname The file name of the mime types file.
*/
public MimeTypeFile(String new_fname) throws IOException {
File mime_file = null;
FileReader fr = null;
fname = new_fname; // remember the file name
mime_file = new File(fname); // get a file object
fr = new FileReader(mime_file);
try {
parse(new BufferedReader(fr));
} finally {
try {
fr.close(); // close it
} catch (IOException e) {
// ignore it
}
}
}
public MimeTypeFile(InputStream is) throws IOException {
parse(new BufferedReader(new InputStreamReader(is, "iso-8859-1")));
}
/**
* Creates an empty DB.
*/
public MimeTypeFile() {
}
/**
* get the MimeTypeEntry based on the file extension
*/
public MimeTypeEntry getMimeTypeEntry(String file_ext) {
return (MimeTypeEntry)type_hash.get((Object)file_ext);
}
/**
* Get the MIME type string corresponding to the file extension.
*/
public String getMIMETypeString(String file_ext) {
MimeTypeEntry entry = this.getMimeTypeEntry(file_ext);
if (entry != null)
return entry.getMIMEType();
else
return null;
}
/**
* Appends string of entries to the types registry, must be valid
* .mime.types format.
* A mime.types entry is one of two forms:
*
* type/subtype ext1 ext2 ...
* or
* type=type/subtype desc="description of type" exts=ext1,ext2,...
*
* Example:
* # this is a test
* audio/basic au
* text/plain txt text
* type=application/postscript exts=ps,eps
*/
public void appendToRegistry(String mime_types) {
try {
parse(new BufferedReader(new StringReader(mime_types)));
} catch (IOException ex) {
// can't happen
}
}
/**
* Parse a stream of mime.types entries.
*/
private void parse(BufferedReader buf_reader) throws IOException {
String line = null, prev = null;
while ((line = buf_reader.readLine()) != null) {
if (prev == null)
prev = line;
else
prev += line;
int end = prev.length();
if (prev.length() > 0 && prev.charAt(end - 1) == '\\') {
prev = prev.substring(0, end - 1);
continue;
}
this.parseEntry(prev);
prev = null;
}
if (prev != null)
this.parseEntry(prev);
}
/**
* Parse single mime.types entry.
*/
private void parseEntry(String line) {
String mime_type = null;
String file_ext = null;
line = line.trim();
if (line.length() == 0) // empty line...
return; // BAIL!
// check to see if this is a comment line?
if (line.charAt(0) == '#')
return; // then we are done!
// is it a new format line or old format?
if (line.indexOf('=') > 0) {
// new format
LineTokenizer lt = new LineTokenizer(line);
while (lt.hasMoreTokens()) {
String name = lt.nextToken();
String value = null;
if (lt.hasMoreTokens() && lt.nextToken().equals("=") &&
lt.hasMoreTokens())
value = lt.nextToken();
if (value == null) {
if (LogSupport.isLoggable())
LogSupport.log("Bad .mime.types entry: " + line);
return;
}
if (name.equals("type"))
mime_type = value;
else if (name.equals("exts")) {
StringTokenizer st = new StringTokenizer(value, ",");
while (st.hasMoreTokens()) {
file_ext = st.nextToken();
MimeTypeEntry entry =
new MimeTypeEntry(mime_type, file_ext);
type_hash.put(file_ext, entry);
if (LogSupport.isLoggable())
LogSupport.log("Added: " + entry.toString());
}
}
}
} else {
// old format
// count the tokens
StringTokenizer strtok = new StringTokenizer(line);
int num_tok = strtok.countTokens();
if (num_tok == 0) // empty line
return;
mime_type = strtok.nextToken(); // get the MIME type
while (strtok.hasMoreTokens()) {
MimeTypeEntry entry = null;
file_ext = strtok.nextToken();
entry = new MimeTypeEntry(mime_type, file_ext);
type_hash.put(file_ext, entry);
if (LogSupport.isLoggable())
LogSupport.log("Added: " + entry.toString());
}
}
}
// for debugging
/*
public static void main(String[] argv) throws Exception {
MimeTypeFile mf = new MimeTypeFile(argv[0]);
System.out.println("ext " + argv[1] + " type " +
mf.getMIMETypeString(argv[1]));
System.exit(0);
}
*/
}
class LineTokenizer {
private int currentPosition;
private int maxPosition;
private String str;
private Vector stack = new Vector();
private static final String singles = "="; // single character tokens
/**
* Constructs a tokenizer for the specified string.
* <p>
*
* @param str a string to be parsed.
*/
public LineTokenizer(String str) {
currentPosition = 0;
this.str = str;
maxPosition = str.length();
}
/**
* Skips white space.
*/
private void skipWhiteSpace() {
while ((currentPosition < maxPosition) &&
Character.isWhitespace(str.charAt(currentPosition))) {
currentPosition++;
}
}
/**
* Tests if there are more tokens available from this tokenizer's string.
*
* @return <code>true</code> if there are more tokens available from this
* tokenizer's string; <code>false</code> otherwise.
*/
public boolean hasMoreTokens() {
if (stack.size() > 0)
return true;
skipWhiteSpace();
return (currentPosition < maxPosition);
}
/**
* Returns the next token from this tokenizer.
*
* @return the next token from this tokenizer.
* @exception NoSuchElementException if there are no more tokens in this
* tokenizer's string.
*/
public String nextToken() {
int size = stack.size();
if (size > 0) {
String t = (String)stack.elementAt(size - 1);
stack.removeElementAt(size - 1);
return t;
}
skipWhiteSpace();
if (currentPosition >= maxPosition) {
throw new NoSuchElementException();
}
int start = currentPosition;
char c = str.charAt(start);
if (c == '"') {
currentPosition++;
boolean filter = false;
while (currentPosition < maxPosition) {
c = str.charAt(currentPosition++);
if (c == '\\') {
currentPosition++;
filter = true;
} else if (c == '"') {
String s;
if (filter) {
StringBuffer sb = new StringBuffer();
for (int i = start + 1; i < currentPosition - 1; i++) {
c = str.charAt(i);
if (c != '\\')
sb.append(c);
}
s = sb.toString();
} else
s = str.substring(start + 1, currentPosition - 1);
return s;
}
}
} else if (singles.indexOf(c) >= 0) {
currentPosition++;
} else {
while ((currentPosition < maxPosition) &&
singles.indexOf(str.charAt(currentPosition)) < 0 &&
!Character.isWhitespace(str.charAt(currentPosition))) {
currentPosition++;
}
}
return str.substring(start, currentPosition);
}
public void pushToken(String token) {
stack.addElement(token);
}
}

View file

@ -1,249 +0,0 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.awt.datatransfer.DataFlavor;
import java.io.IOException;
import javax.activation.MimeType;
/**
* The ActivationDataFlavor class is a special subclass of
* {@code java.awt.datatransfer.DataFlavor}. It allows the JAF to
* set all three values stored by the DataFlavor class via a new
* constructor. It also contains improved MIME parsing in the {@code equals}
* method. Except for the improved parsing, its semantics are
* identical to that of the JDK's DataFlavor class.
*
* @since 1.6
*/
public class ActivationDataFlavor extends DataFlavor {
/*
* Raison d'etre:
*
* The DataFlavor class included in JDK 1.1 has several limitations
* including piss poor MIME type parsing, and the limitation of
* only supporting serialized objects and InputStreams as
* representation objects. This class 'fixes' that.
*/
// I think for now I'll keep copies of all the variables and
// then later I may choose try to better coexist with the base
// class *sigh*
private String mimeType = null;
private MimeType mimeObject = null;
private String humanPresentableName = null;
private Class representationClass = null;
/**
* Construct a DataFlavor that represents an arbitrary
* Java object. This constructor is an extension of the
* JDK's DataFlavor in that it allows the explicit setting
* of all three DataFlavor attributes.
* <p>
* The returned DataFlavor will have the following characteristics:
* <p>
* representationClass = representationClass<br>
* mimeType = mimeType<br>
* humanName = humanName
*
* @param representationClass the class used in this DataFlavor
* @param mimeType the MIME type of the data represented by this class
* @param humanPresentableName the human presentable name of the flavor
*/
public ActivationDataFlavor(Class representationClass,
String mimeType, String humanPresentableName) {
super(mimeType, humanPresentableName); // need to call super
// init private variables:
this.mimeType = mimeType;
this.humanPresentableName = humanPresentableName;
this.representationClass = representationClass;
}
/**
* Construct a DataFlavor that represents a MimeType.
* <p>
* The returned DataFlavor will have the following characteristics:
* <p>
* If the mimeType is "application/x-java-serialized-object;
* class=", the result is the same as calling new
* DataFlavor(Class.forName()) as above.
* <p>
* otherwise:
* <p>
* representationClass = InputStream<p>
* mimeType = mimeType
*
* @param representationClass the class used in this DataFlavor
* @param humanPresentableName the human presentable name of the flavor
*/
public ActivationDataFlavor(Class representationClass,
String humanPresentableName) {
super(representationClass, humanPresentableName);
this.mimeType = super.getMimeType();
this.representationClass = representationClass;
this.humanPresentableName = humanPresentableName;
}
/**
* Construct a DataFlavor that represents a MimeType.
* <p>
* The returned DataFlavor will have the following characteristics:
* <p>
* If the mimeType is "application/x-java-serialized-object; class=",
* the result is the same as calling new DataFlavor(Class.forName()) as
* above, otherwise:
* <p>
* representationClass = InputStream<p>
* mimeType = mimeType
*
* @param mimeType the MIME type of the data represented by this class
* @param humanPresentableName the human presentable name of the flavor
*/
public ActivationDataFlavor(String mimeType, String humanPresentableName) {
super(mimeType, humanPresentableName);
this.mimeType = mimeType;
try {
this.representationClass = Class.forName("java.io.InputStream");
} catch (ClassNotFoundException ex) {
// XXX - should never happen, ignore it
}
this.humanPresentableName = humanPresentableName;
}
/**
* Return the MIME type for this DataFlavor.
*
* @return the MIME type
*/
public String getMimeType() {
return mimeType;
}
/**
* Return the representation class.
*
* @return the representation class
*/
public Class getRepresentationClass() {
return representationClass;
}
/**
* Return the Human Presentable name.
*
* @return the human presentable name
*/
public String getHumanPresentableName() {
return humanPresentableName;
}
/**
* Set the human presentable name.
*
* @param humanPresentableName the name to set
*/
public void setHumanPresentableName(String humanPresentableName) {
this.humanPresentableName = humanPresentableName;
}
/**
* Compares the DataFlavor passed in with this DataFlavor; calls
* the {@code isMimeTypeEqual} method.
*
* @param dataFlavor the DataFlavor to compare with
* @return true if the MIME type and representation class
* are the same
*/
public boolean equals(DataFlavor dataFlavor) {
return (isMimeTypeEqual(dataFlavor) &&
dataFlavor.getRepresentationClass() == representationClass);
}
/**
* Is the string representation of the MIME type passed in equivalent
* to the MIME type of this DataFlavor. <p>
*
* ActivationDataFlavor delegates the comparison of MIME types to
* the MimeType class included as part of the JavaBeans Activation
* Framework. This provides a more robust comparison than is normally
* available in the DataFlavor class.
*
* @param mimeType the MIME type
* @return true if the same MIME type
*/
public boolean isMimeTypeEqual(String mimeType) {
MimeType mt = null;
try {
if (mimeObject == null)
mimeObject = new MimeType(this.mimeType);
mt = new MimeType(mimeType);
} catch (MimeTypeParseException e) {
// something didn't parse, do a crude comparison
return this.mimeType.equalsIgnoreCase(mimeType);
}
return mimeObject.match(mt);
}
/**
* Called on DataFlavor for every MIME Type parameter to allow DataFlavor
* subclasses to handle special parameters like the text/plain charset
* parameters, whose values are case insensitive. (MIME type parameter
* values are supposed to be case sensitive).
* <p>
* This method is called for each parameter name/value pair and should
* return the normalized representation of the parameterValue.
* This method is never invoked by this implementation.
*
* @param parameterName the parameter name
* @param parameterValue the parameter value
* @return the normalized parameter value
* @deprecated
*/
protected String normalizeMimeTypeParameter(String parameterName,
String parameterValue) {
return parameterValue;
}
/**
* Called for each MIME type string to give DataFlavor subtypes the
* opportunity to change how the normalization of MIME types is
* accomplished.
* One possible use would be to add default parameter/value pairs in cases
* where none are present in the MIME type string passed in.
* This method is never invoked by this implementation.
*
* @param mimeType the MIME type
* @return the normalized MIME type
* @deprecated
*/
protected String normalizeMimeType(String mimeType) {
return mimeType;
}
}

View file

@ -1,233 +0,0 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
/**
* The CommandInfo class is used by CommandMap implementations to
* describe the results of command requests. It provides the requestor
* with both the verb requested, as well as an instance of the
* bean. There is also a method that will return the name of the
* class that implements the command but <i>it is not guaranteed to
* return a valid value</i>. The reason for this is to allow CommandMap
* implmentations that subclass CommandInfo to provide special
* behavior. For example a CommandMap could dynamically generate
* JavaBeans. In this case, it might not be possible to create an
* object with all the correct state information solely from the class
* name.
*
* @since 1.6
*/
public class CommandInfo {
private String verb;
private String className;
/**
* The Constructor for CommandInfo.
* @param verb The command verb this CommandInfo decribes.
* @param className The command's fully qualified class name.
*/
public CommandInfo(String verb, String className) {
this.verb = verb;
this.className = className;
}
/**
* Return the command verb.
*
* @return the command verb.
*/
public String getCommandName() {
return verb;
}
/**
* Return the command's class name. <i>This method MAY return null in
* cases where a CommandMap subclassed CommandInfo for its
* own purposes.</i> In other words, it might not be possible to
* create the correct state in the command by merely knowing
* its class name. <b>DO NOT DEPEND ON THIS METHOD RETURNING
* A VALID VALUE!</b>
*
* @return The class name of the command, or <i>null</i>
*/
public String getCommandClass() {
return className;
}
/**
* Return the instantiated JavaBean component.
* <p>
* If {@code java.beans.Beans} is visible then it's
* {@code java.beans.Beans#instantiate} method is invoked to instantiate
* the component as a JavaBeans component.
* When {@code java.beans.Beans} is not visible (when {@code java.desktop}
* module is not readable or when the runtime image does not contain the
* {@code java.desktop} module) then the command's class is loaded and
* instantiated with its public no-args constructor.
* <p>
* The component class needs to be public.
* <p>
* If the bean implements the {@code javax.activation.CommandObject}
* interface, call its {@code setCommandContext} method.
* <p>
* If the DataHandler parameter is null, then the bean is
* instantiated with no data. NOTE: this may be useful
* if for some reason the DataHandler that is passed in
* throws IOExceptions when this method attempts to
* access its InputStream. It will allow the caller to
* retrieve a reference to the bean if it can be
* instantiated.
* <p>
* If the bean does NOT implement the CommandObject interface,
* this method will check if it implements the
* java.io.Externalizable interface. If it does, the bean's
* readExternal method will be called if an InputStream
* can be acquired from the DataHandler.
*
* @param dh The DataHandler that describes the data to be
* passed to the command.
* @param loader The ClassLoader to be used to instantiate the bean.
* @return The bean
* @exception IOException for failures reading data
* @exception ClassNotFoundException if command object class can't
* be found
* @see java.beans.Beans#instantiate
* @see javax.activation.CommandObject
*/
public Object getCommandObject(DataHandler dh, ClassLoader loader)
throws IOException, ClassNotFoundException {
Object new_bean = null;
// try to instantiate the bean
new_bean = Beans.instantiate(loader, className);
// if we got one and it is a CommandObject
if (new_bean != null) {
if (new_bean instanceof CommandObject) {
((CommandObject)new_bean).setCommandContext(verb, dh);
} else if (new_bean instanceof Externalizable) {
if (dh != null) {
InputStream is = dh.getInputStream();
if (is != null) {
((Externalizable)new_bean).readExternal(
new ObjectInputStream(is));
}
}
}
}
return new_bean;
}
/**
* Helper class to invoke Beans.instantiate reflectively or the equivalent
* with core reflection when module java.desktop is not readable.
*/
private static final class Beans {
static final Method instantiateMethod;
static {
Method m;
try {
Class<?> c = Class.forName("java.beans.Beans");
m = c.getDeclaredMethod("instantiate", ClassLoader.class, String.class);
} catch (ClassNotFoundException e) {
m = null;
} catch (NoSuchMethodException e) {
m = null;
}
instantiateMethod = m;
}
/**
* Equivalent to invoking java.beans.Beans.instantiate(loader, cn)
*/
static Object instantiate(ClassLoader loader, String cn)
throws IOException, ClassNotFoundException {
Exception exception;
if (instantiateMethod != null) {
// invoke Beans.instantiate
try {
return instantiateMethod.invoke(null, loader, cn);
} catch (InvocationTargetException e) {
exception = e;
} catch (IllegalAccessException e) {
exception = e;
}
} else {
SecurityManager security = System.getSecurityManager();
if (security != null) {
// if it's ok with the SecurityManager, it's ok with me.
String cname = cn.replace('/', '.');
if (cname.startsWith("[")) {
int b = cname.lastIndexOf('[') + 2;
if (b > 1 && b < cname.length()) {
cname = cname.substring(b);
}
}
int i = cname.lastIndexOf('.');
if (i != -1) {
security.checkPackageAccess(cname.substring(0, i));
}
}
// Beans.instantiate specified to use SCL when loader is null
if (loader == null) {
loader = (ClassLoader)
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
ClassLoader cl = null;
try {
cl = ClassLoader.getSystemClassLoader();
} catch (SecurityException ex) { }
return cl;
}
});
}
Class<?> beanClass = Class.forName(cn, false, loader);
try {
return beanClass.getDeclaredConstructor().newInstance();
} catch (Exception ex) {
throw new ClassNotFoundException(beanClass + ": " + ex, ex);
}
}
return null;
}
}
}

View file

@ -1,235 +0,0 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.util.Map;
import java.util.WeakHashMap;
/**
* The CommandMap class provides an interface to a registry of
* command objects available in the system.
* Developers are expected to either use the CommandMap
* implementation included with this package (MailcapCommandMap) or
* develop their own. Note that some of the methods in this class are
* abstract.
*
* @since 1.6
*/
public abstract class CommandMap {
private static CommandMap defaultCommandMap = null;
private static Map<ClassLoader,CommandMap> map =
new WeakHashMap<ClassLoader,CommandMap>();
/**
* Get the default CommandMap.
*
* <ul>
* <li> In cases where a CommandMap instance has been previously set
* to some value (via <i>setDefaultCommandMap</i>)
* return the CommandMap.
* <li>
* In cases where no CommandMap has been set, the CommandMap
* creates an instance of {@code MailcapCommandMap} and
* set that to the default, returning its value.
*
* </ul>
*
* @return the CommandMap
*/
public static synchronized CommandMap getDefaultCommandMap() {
if (defaultCommandMap != null)
return defaultCommandMap;
// fetch per-thread-context-class-loader default
ClassLoader tccl = SecuritySupport.getContextClassLoader();
CommandMap def = map.get(tccl);
if (def == null) {
def = new MailcapCommandMap();
map.put(tccl, def);
}
return def;
}
/**
* Set the default CommandMap. Reset the CommandMap to the default by
* calling this method with {@code null}.
*
* @param commandMap The new default CommandMap.
* @exception SecurityException if the caller doesn't have permission
* to change the default
*/
public static synchronized void setDefaultCommandMap(CommandMap commandMap) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
try {
// if it's ok with the SecurityManager, it's ok with me...
security.checkSetFactory();
} catch (SecurityException ex) {
// otherwise, we also allow it if this code and the
// factory come from the same (non-system) class loader (e.g.,
// the JAF classes were loaded with the applet classes).
ClassLoader cl = CommandMap.class.getClassLoader();
if (cl == null || cl.getParent() == null ||
cl != commandMap.getClass().getClassLoader()) {
throw ex;
}
}
}
// remove any per-thread-context-class-loader CommandMap
map.remove(SecuritySupport.getContextClassLoader());
defaultCommandMap = commandMap;
}
/**
* Get the preferred command list from a MIME Type. The actual semantics
* are determined by the implementation of the CommandMap.
*
* @param mimeType the MIME type
* @return the CommandInfo classes that represent the command Beans.
*/
abstract public CommandInfo[] getPreferredCommands(String mimeType);
/**
* Get the preferred command list from a MIME Type. The actual semantics
* are determined by the implementation of the CommandMap. <p>
*
* The {@code DataSource} provides extra information, such as
* the file name, that a CommandMap implementation may use to further
* refine the list of commands that are returned. The implementation
* in this class simply calls the {@code getPreferredCommands}
* method that ignores this argument.
*
* @param mimeType the MIME type
* @param ds a DataSource for the data
* @return the CommandInfo classes that represent the command Beans.
* @since 1.6, JAF 1.1
*/
public CommandInfo[] getPreferredCommands(String mimeType, DataSource ds) {
return getPreferredCommands(mimeType);
}
/**
* Get all the available commands for this type. This method
* should return all the possible commands for this MIME type.
*
* @param mimeType the MIME type
* @return the CommandInfo objects representing all the commands.
*/
abstract public CommandInfo[] getAllCommands(String mimeType);
/**
* Get all the available commands for this type. This method
* should return all the possible commands for this MIME type. <p>
*
* The {@code DataSource} provides extra information, such as
* the file name, that a CommandMap implementation may use to further
* refine the list of commands that are returned. The implementation
* in this class simply calls the {@code getAllCommands}
* method that ignores this argument.
*
* @param mimeType the MIME type
* @param ds a DataSource for the data
* @return the CommandInfo objects representing all the commands.
* @since 1.6, JAF 1.1
*/
public CommandInfo[] getAllCommands(String mimeType, DataSource ds) {
return getAllCommands(mimeType);
}
/**
* Get the default command corresponding to the MIME type.
*
* @param mimeType the MIME type
* @param cmdName the command name
* @return the CommandInfo corresponding to the command.
*/
abstract public CommandInfo getCommand(String mimeType, String cmdName);
/**
* Get the default command corresponding to the MIME type. <p>
*
* The {@code DataSource} provides extra information, such as
* the file name, that a CommandMap implementation may use to further
* refine the command that is chosen. The implementation
* in this class simply calls the {@code getCommand}
* method that ignores this argument.
*
* @param mimeType the MIME type
* @param cmdName the command name
* @param ds a DataSource for the data
* @return the CommandInfo corresponding to the command.
* @since 1.6, JAF 1.1
*/
public CommandInfo getCommand(String mimeType, String cmdName,
DataSource ds) {
return getCommand(mimeType, cmdName);
}
/**
* Locate a DataContentHandler that corresponds to the MIME type.
* The mechanism and semantics for determining this are determined
* by the implementation of the particular CommandMap.
*
* @param mimeType the MIME type
* @return the DataContentHandler for the MIME type
*/
abstract public DataContentHandler createDataContentHandler(String
mimeType);
/**
* Locate a DataContentHandler that corresponds to the MIME type.
* The mechanism and semantics for determining this are determined
* by the implementation of the particular CommandMap. <p>
*
* The {@code DataSource} provides extra information, such as
* the file name, that a CommandMap implementation may use to further
* refine the choice of DataContentHandler. The implementation
* in this class simply calls the {@code createDataContentHandler}
* method that ignores this argument.
*
* @param mimeType the MIME type
* @param ds a DataSource for the data
* @return the DataContentHandler for the MIME type
* @since 1.6, JAF 1.1
*/
public DataContentHandler createDataContentHandler(String mimeType,
DataSource ds) {
return createDataContentHandler(mimeType);
}
/**
* Get all the MIME types known to this command map.
* If the command map doesn't support this operation,
* null is returned.
*
* @return array of MIME types as strings, or null if not supported
* @since 1.6, JAF 1.1
*/
public String[] getMimeTypes() {
return null;
}
}

View file

@ -1,55 +0,0 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.io.IOException;
/**
* JavaBeans components that are Activation Framework aware implement
* this interface to find out which command verb they're being asked
* to perform, and to obtain the DataHandler representing the
* data they should operate on. JavaBeans that don't implement
* this interface may be used as well. Such commands may obtain
* the data using the Externalizable interface, or using an
* application-specific method.
*
* @since 1.6
*/
public interface CommandObject {
/**
* Initialize the Command with the verb it is requested to handle
* and the DataHandler that describes the data it will
* operate on. <b>NOTE:</b> it is acceptable for the caller
* to pass <i>null</i> as the value for {@code DataHandler}.
*
* @param verb The Command Verb this object refers to.
* @param dh The DataHandler.
* @exception IOException for failures accessing data
*/
public void setCommandContext(String verb, DataHandler dh)
throws IOException;
}

View file

@ -1,106 +0,0 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.activation.DataSource;
/**
* <p>The DataContentHandler interface is implemented by objects that can
* be used to extend the capabilities of the DataHandler's implementation
* of the Transferable interface. Through <code>DataContentHandlers</code>
* the framework can be extended to convert streams in to objects, and
* to write objects to streams.</p>
*
* <p>An implementation of DataContentHandler should be a public class
* with a public no-arg constructor. If the implementation class is in
* a named module then it should be in an API package that is exported
* to the module {@code java.activation}.</p>
*
* <p>Applications don't generally call the methods in DataContentHandlers
* directly. Instead, an application calls the equivalent methods in
* DataHandler. The DataHandler will attempt to find an appropriate
* DataContentHandler that corresponds to its MIME type using the
* current DataContentHandlerFactory. The DataHandler then calls
* through to the methods in the DataContentHandler.</p>
*
* @since 1.6
*/
public interface DataContentHandler {
/**
* Returns an array of DataFlavor objects indicating the flavors the
* data can be provided in. The array should be ordered according to
* preference for providing the data (from most richly descriptive to
* least descriptive).
*
* @return The DataFlavors.
*/
public DataFlavor[] getTransferDataFlavors();
/**
* Returns an object which represents the data to be transferred.
* The class of the object returned is defined by the representation class
* of the flavor.
*
* @param df The DataFlavor representing the requested type.
* @param ds The DataSource representing the data to be converted.
* @return The constructed Object.
* @exception UnsupportedFlavorException if the handler doesn't
* support the requested flavor
* @exception IOException if the data can't be accessed
*/
public Object getTransferData(DataFlavor df, DataSource ds)
throws UnsupportedFlavorException, IOException;
/**
* Return an object representing the data in its most preferred form.
* Generally this will be the form described by the first DataFlavor
* returned by the <code>getTransferDataFlavors</code> method.
*
* @param ds The DataSource representing the data to be converted.
* @return The constructed Object.
* @exception IOException if the data can't be accessed
*/
public Object getContent(DataSource ds) throws IOException;
/**
* Convert the object to a byte stream of the specified MIME type
* and write it to the output stream.
*
* @param obj The object to be converted.
* @param mimeType The requested MIME type of the resulting byte stream.
* @param os The output stream into which to write the converted
* byte stream.
* @exception IOException errors writing to the stream
*/
public void writeTo(Object obj, String mimeType, OutputStream os)
throws IOException;
}

View file

@ -1,48 +0,0 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
/**
* This interface defines a factory for <code>DataContentHandlers</code>. An
* implementation of this interface should map a MIME type into an
* instance of DataContentHandler. The design pattern for classes implementing
* this interface is the same as for the ContentHandler mechanism used in
* <code>java.net.URL</code>.
*
* @since 1.6
*/
public interface DataContentHandlerFactory {
/**
* Creates a new DataContentHandler object for the MIME type.
*
* @param mimeType the MIME type to create the DataContentHandler for.
* @return The new <code>DataContentHandler</code>, or <i>null</i>
* if none are found.
*/
public DataContentHandler createDataContentHandler(String mimeType);
}

View file

@ -1,900 +0,0 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
/**
* The DataHandler class provides a consistent interface to data
* available in many different sources and formats.
* It manages simple stream to string conversions and related operations
* using DataContentHandlers.
* It provides access to commands that can operate on the data.
* The commands are found using a CommandMap. <p>
*
* <b>DataHandler and the Transferable Interface</b><p>
* DataHandler implements the Transferable interface so that data can
* be used in AWT data transfer operations, such as cut and paste and
* drag and drop. The implementation of the Transferable interface
* relies on the availability of an installed DataContentHandler
* object corresponding to the MIME type of the data represented in
* the specific instance of the DataHandler.<p>
*
* <b>DataHandler and CommandMaps</b><p>
* The DataHandler keeps track of the current CommandMap that it uses to
* service requests for commands ({@code getCommand, getAllCommands,
* getPreferredCommands}).
* Each instance of a DataHandler may have a CommandMap associated with
* it using the {@code setCommandMap} method. If a CommandMap was
* not set, DataHandler calls the {@code getDefaultCommandMap}
* method in CommandMap and uses the value it returns. See
* <i>CommandMap</i> for more information. <p>
*
* <b>DataHandler and URLs</b><p>
* The current DataHandler implementation creates a private
* instance of URLDataSource when it is constructed with a URL.
*
* @see javax.activation.CommandMap
* @see javax.activation.DataContentHandler
* @see javax.activation.DataSource
* @see javax.activation.URLDataSource
*
* @since 1.6
*/
public class DataHandler implements Transferable {
// Use the datasource to indicate whether we were started via the
// DataSource constructor or the object constructor.
private DataSource dataSource = null;
private DataSource objDataSource = null;
// The Object and mimetype from the constructor (if passed in).
// object remains null if it was instantiated with a
// DataSource.
private Object object = null;
private String objectMimeType = null;
// Keep track of the CommandMap
private CommandMap currentCommandMap = null;
// our transfer flavors
private static final DataFlavor emptyFlavors[] = new DataFlavor[0];
private DataFlavor transferFlavors[] = emptyFlavors;
// our DataContentHandler
private DataContentHandler dataContentHandler = null;
private DataContentHandler factoryDCH = null;
// our DataContentHandlerFactory
private static DataContentHandlerFactory factory = null;
private DataContentHandlerFactory oldFactory = null;
// the short representation of the ContentType (sans params)
private String shortType = null;
/**
* Create a {@code DataHandler} instance referencing the
* specified DataSource. The data exists in a byte stream form.
* The DataSource will provide an InputStream to access the data.
*
* @param ds the DataSource
*/
public DataHandler(DataSource ds) {
// save a reference to the incoming DS
dataSource = ds;
oldFactory = factory; // keep track of the factory
}
/**
* Create a {@code DataHandler} instance representing an object
* of this MIME type. This constructor is
* used when the application already has an in-memory representation
* of the data in the form of a Java Object.
*
* @param obj the Java Object
* @param mimeType the MIME type of the object
*/
public DataHandler(Object obj, String mimeType) {
object = obj;
objectMimeType = mimeType;
oldFactory = factory; // keep track of the factory
}
/**
* Create a {@code DataHandler} instance referencing a URL.
* The DataHandler internally creates a {@code URLDataSource}
* instance to represent the URL.
*
* @param url a URL object
*/
public DataHandler(URL url) {
dataSource = new URLDataSource(url);
oldFactory = factory; // keep track of the factory
}
/**
* Return the CommandMap for this instance of DataHandler.
*/
private synchronized CommandMap getCommandMap() {
if (currentCommandMap != null)
return currentCommandMap;
else
return CommandMap.getDefaultCommandMap();
}
/**
* Return the DataSource associated with this instance
* of DataHandler.
* <p>
* For DataHandlers that have been instantiated with a DataSource,
* this method returns the DataSource that was used to create the
* DataHandler object. In other cases the DataHandler
* constructs a DataSource from the data used to construct
* the DataHandler. DataSources created for DataHandlers <b>not</b>
* instantiated with a DataSource are cached for performance
* reasons.
*
* @return a valid DataSource object for this DataHandler
*/
public DataSource getDataSource() {
if (dataSource == null) {
// create one on the fly
if (objDataSource == null)
objDataSource = new DataHandlerDataSource(this);
return objDataSource;
}
return dataSource;
}
/**
* Return the name of the data object. If this DataHandler
* was created with a DataSource, this method calls through
* to the {@code DataSource.getName} method, otherwise it
* returns <i>null</i>.
*
* @return the name of the object
*/
public String getName() {
if (dataSource != null)
return dataSource.getName();
else
return null;
}
/**
* Return the MIME type of this object as retrieved from
* the source object. Note that this is the <i>full</i>
* type with parameters.
*
* @return the MIME type
*/
public String getContentType() {
if (dataSource != null) // data source case
return dataSource.getContentType();
else
return objectMimeType; // obj/type case
}
/**
* Get the InputStream for this object. <p>
*
* For DataHandlers instantiated with a DataSource, the DataHandler
* calls the {@code DataSource.getInputStream} method and
* returns the result to the caller.
* <p>
* For DataHandlers instantiated with an Object, the DataHandler
* first attempts to find a DataContentHandler for the Object. If
* the DataHandler can not find a DataContentHandler for this MIME
* type, it throws an UnsupportedDataTypeException. If it is
* successful, it creates a pipe and a thread. The thread uses the
* DataContentHandler's {@code writeTo} method to write the
* stream data into one end of the pipe. The other end of the pipe
* is returned to the caller. Because a thread is created to copy
* the data, IOExceptions that may occur during the copy can not be
* propagated back to the caller. The result is an empty stream.
*
* @return the InputStream representing this data
* @exception IOException if an I/O error occurs
*
* @see javax.activation.DataContentHandler#writeTo
* @see javax.activation.UnsupportedDataTypeException
*/
public InputStream getInputStream() throws IOException {
InputStream ins = null;
if (dataSource != null) {
ins = dataSource.getInputStream();
} else {
DataContentHandler dch = getDataContentHandler();
// we won't even try if we can't get a dch
if (dch == null)
throw new UnsupportedDataTypeException(
"no DCH for MIME type " + getBaseType());
if (dch instanceof ObjectDataContentHandler) {
if (((ObjectDataContentHandler)dch).getDCH() == null)
throw new UnsupportedDataTypeException(
"no object DCH for MIME type " + getBaseType());
}
// there is none but the default^^^^^^^^^^^^^^^^
final DataContentHandler fdch = dch;
// from bill s.
// ce n'est pas une pipe!
//
// NOTE: This block of code needs to throw exceptions, but
// can't because it is in another thread!!! ARG!
//
final PipedOutputStream pos = new PipedOutputStream();
PipedInputStream pin = new PipedInputStream(pos);
new Thread(
new Runnable() {
public void run() {
try {
fdch.writeTo(object, objectMimeType, pos);
} catch (IOException e) {
} finally {
try {
pos.close();
} catch (IOException ie) { }
}
}
},
"DataHandler.getInputStream").start();
ins = pin;
}
return ins;
}
/**
* Write the data to an {@code OutputStream}.<p>
*
* If the DataHandler was created with a DataSource, writeTo
* retrieves the InputStream and copies the bytes from the
* InputStream to the OutputStream passed in.
* <p>
* If the DataHandler was created with an object, writeTo
* retrieves the DataContentHandler for the object's type.
* If the DataContentHandler was found, it calls the
* {@code writeTo} method on the {@code DataContentHandler}.
*
* @param os the OutputStream to write to
* @exception IOException if an I/O error occurs
*/
public void writeTo(OutputStream os) throws IOException {
// for the DataSource case
if (dataSource != null) {
InputStream is = null;
byte data[] = new byte[8*1024];
int bytes_read;
is = dataSource.getInputStream();
try {
while ((bytes_read = is.read(data)) > 0) {
os.write(data, 0, bytes_read);
}
} finally {
is.close();
is = null;
}
} else { // for the Object case
DataContentHandler dch = getDataContentHandler();
dch.writeTo(object, objectMimeType, os);
}
}
/**
* Get an OutputStream for this DataHandler to allow overwriting
* the underlying data.
* If the DataHandler was created with a DataSource, the
* DataSource's {@code getOutputStream} method is called.
* Otherwise, {@code null} is returned.
*
* @return the OutputStream
* @exception IOException for failures creating the OutputStream
*
* @see javax.activation.DataSource#getOutputStream
* @see javax.activation.URLDataSource
*/
public OutputStream getOutputStream() throws IOException {
if (dataSource != null)
return dataSource.getOutputStream();
else
return null;
}
/**
* Return the DataFlavors in which this data is available. <p>
*
* Returns an array of DataFlavor objects indicating the flavors
* the data can be provided in. The array is usually ordered
* according to preference for providing the data, from most
* richly descriptive to least richly descriptive.<p>
*
* The DataHandler attempts to find a DataContentHandler that
* corresponds to the MIME type of the data. If one is located,
* the DataHandler calls the DataContentHandler's
* {@code getTransferDataFlavors} method. <p>
*
* If a DataContentHandler can <i>not</i> be located, and if the
* DataHandler was created with a DataSource (or URL), one
* DataFlavor is returned that represents this object's MIME type
* and the {@code java.io.InputStream} class. If the
* DataHandler was created with an object and a MIME type,
* getTransferDataFlavors returns one DataFlavor that represents
* this object's MIME type and the object's class.
*
* @return an array of data flavors in which this data can be transferred
* @see javax.activation.DataContentHandler#getTransferDataFlavors
*/
public synchronized DataFlavor[] getTransferDataFlavors() {
if (factory != oldFactory) // if the factory has changed, clear cache
transferFlavors = emptyFlavors;
// if it's not set, set it...
if (transferFlavors == emptyFlavors)
transferFlavors = getDataContentHandler().getTransferDataFlavors();
if (transferFlavors == emptyFlavors)
return transferFlavors;
else
return transferFlavors.clone();
}
/**
* Returns whether the specified data flavor is supported
* for this object.<p>
*
* This method iterates through the DataFlavors returned from
* {@code getTransferDataFlavors}, comparing each with
* the specified flavor.
*
* @param flavor the requested flavor for the data
* @return true if the data flavor is supported
* @see javax.activation.DataHandler#getTransferDataFlavors
*/
public boolean isDataFlavorSupported(DataFlavor flavor) {
DataFlavor[] lFlavors = getTransferDataFlavors();
for (int i = 0; i < lFlavors.length; i++) {
if (lFlavors[i].equals(flavor))
return true;
}
return false;
}
/**
* Returns an object that represents the data to be
* transferred. The class of the object returned is defined by the
* representation class of the data flavor.<p>
*
* <b>For DataHandler's created with DataSources or URLs:</b><p>
*
* The DataHandler attempts to locate a DataContentHandler
* for this MIME type. If one is found, the passed in DataFlavor
* and the type of the data are passed to its {@code getTransferData}
* method. If the DataHandler fails to locate a DataContentHandler
* and the flavor specifies this object's MIME type and the
* {@code java.io.InputStream} class, this object's InputStream
* is returned.
* Otherwise it throws an UnsupportedFlavorException. <p>
*
* <b>For DataHandler's created with Objects:</b><p>
*
* The DataHandler attempts to locate a DataContentHandler
* for this MIME type. If one is found, the passed in DataFlavor
* and the type of the data are passed to its getTransferData
* method. If the DataHandler fails to locate a DataContentHandler
* and the flavor specifies this object's MIME type and its class,
* this DataHandler's referenced object is returned.
* Otherwise it throws an UnsupportedFlavorException.
*
* @param flavor the requested flavor for the data
* @return the object
* @exception UnsupportedFlavorException if the data could not be
* converted to the requested flavor
* @exception IOException if an I/O error occurs
* @see javax.activation.ActivationDataFlavor
*/
public Object getTransferData(DataFlavor flavor)
throws UnsupportedFlavorException, IOException {
return getDataContentHandler().getTransferData(flavor, dataSource);
}
/**
* Set the CommandMap for use by this DataHandler.
* Setting it to {@code null} causes the CommandMap to revert
* to the CommandMap returned by the
* {@code CommandMap.getDefaultCommandMap} method.
* Changing the CommandMap, or setting it to {@code null},
* clears out any data cached from the previous CommandMap.
*
* @param commandMap the CommandMap to use in this DataHandler
*
* @see javax.activation.CommandMap#setDefaultCommandMap
*/
public synchronized void setCommandMap(CommandMap commandMap) {
if (commandMap != currentCommandMap || commandMap == null) {
// clear cached values...
transferFlavors = emptyFlavors;
dataContentHandler = null;
currentCommandMap = commandMap;
}
}
/**
* Return the <i>preferred</i> commands for this type of data.
* This method calls the {@code getPreferredCommands} method
* in the CommandMap associated with this instance of DataHandler.
* This method returns an array that represents a subset of
* available commands. In cases where multiple commands for the
* MIME type represented by this DataHandler are present, the
* installed CommandMap chooses the appropriate commands.
*
* @return the CommandInfo objects representing the preferred commands
*
* @see javax.activation.CommandMap#getPreferredCommands
*/
public CommandInfo[] getPreferredCommands() {
if (dataSource != null)
return getCommandMap().getPreferredCommands(getBaseType(),
dataSource);
else
return getCommandMap().getPreferredCommands(getBaseType());
}
/**
* Return all the commands for this type of data.
* This method returns an array containing all commands
* for the type of data represented by this DataHandler. The
* MIME type for the underlying data represented by this DataHandler
* is used to call through to the {@code getAllCommands} method
* of the CommandMap associated with this DataHandler.
*
* @return the CommandInfo objects representing all the commands
*
* @see javax.activation.CommandMap#getAllCommands
*/
public CommandInfo[] getAllCommands() {
if (dataSource != null)
return getCommandMap().getAllCommands(getBaseType(), dataSource);
else
return getCommandMap().getAllCommands(getBaseType());
}
/**
* Get the command <i>cmdName</i>. Use the search semantics as
* defined by the CommandMap installed in this DataHandler. The
* MIME type for the underlying data represented by this DataHandler
* is used to call through to the {@code getCommand} method
* of the CommandMap associated with this DataHandler.
*
* @param cmdName the command name
* @return the CommandInfo corresponding to the command
*
* @see javax.activation.CommandMap#getCommand
*/
public CommandInfo getCommand(String cmdName) {
if (dataSource != null)
return getCommandMap().getCommand(getBaseType(), cmdName,
dataSource);
else
return getCommandMap().getCommand(getBaseType(), cmdName);
}
/**
* Return the data in its preferred Object form. <p>
*
* If the DataHandler was instantiated with an object, return
* the object. <p>
*
* If the DataHandler was instantiated with a DataSource,
* this method uses a DataContentHandler to return the content
* object for the data represented by this DataHandler. If no
* {@code DataContentHandler} can be found for the
* the type of this data, the DataHandler returns an
* InputStream for the data.
*
* @return the content.
* @exception IOException if an IOException occurs during
* this operation.
*/
public Object getContent() throws IOException {
if (object != null)
return object;
else
return getDataContentHandler().getContent(getDataSource());
}
/**
* A convenience method that takes a CommandInfo object
* and instantiates the corresponding command, usually
* a JavaBean component.
* <p>
* This method calls the CommandInfo's {@code getCommandObject}
* method with the {@code ClassLoader} used to load
* the {@code javax.activation.DataHandler} class itself.
*
* @param cmdinfo the CommandInfo corresponding to a command
* @return the instantiated command object
*/
public Object getBean(CommandInfo cmdinfo) {
Object bean = null;
try {
// make the bean
ClassLoader cld = null;
// First try the "application's" class loader.
cld = SecuritySupport.getContextClassLoader();
if (cld == null)
cld = this.getClass().getClassLoader();
bean = cmdinfo.getCommandObject(this, cld);
} catch (IOException e) {
} catch (ClassNotFoundException e) { }
return bean;
}
/**
* Get the DataContentHandler for this DataHandler: <p>
*
* If a DataContentHandlerFactory is set, use it.
* Otherwise look for an object to serve DCH in the
* following order: <p>
*
* 1) if a factory is set, use it <p>
* 2) if a CommandMap is set, use it <p>
* 3) use the default CommandMap <p>
*
* In any case, wrap the real DataContentHandler with one of our own
* to handle any missing cases, fill in defaults, and to ensure that
* we always have a non-null DataContentHandler.
*
* @return the requested DataContentHandler
*/
private synchronized DataContentHandler getDataContentHandler() {
// make sure the factory didn't change
if (factory != oldFactory) {
oldFactory = factory;
factoryDCH = null;
dataContentHandler = null;
transferFlavors = emptyFlavors;
}
if (dataContentHandler != null)
return dataContentHandler;
String simpleMT = getBaseType();
if (factoryDCH == null && factory != null)
factoryDCH = factory.createDataContentHandler(simpleMT);
if (factoryDCH != null)
dataContentHandler = factoryDCH;
if (dataContentHandler == null) {
if (dataSource != null)
dataContentHandler = getCommandMap().
createDataContentHandler(simpleMT, dataSource);
else
dataContentHandler = getCommandMap().
createDataContentHandler(simpleMT);
}
// getDataContentHandler always uses these 'wrapper' handlers
// to make sure it returns SOMETHING meaningful...
if (dataSource != null)
dataContentHandler = new DataSourceDataContentHandler(
dataContentHandler,
dataSource);
else
dataContentHandler = new ObjectDataContentHandler(
dataContentHandler,
object,
objectMimeType);
return dataContentHandler;
}
/**
* Use the MimeType class to extract the MIME type/subtype,
* ignoring the parameters. The type is cached.
*/
private synchronized String getBaseType() {
if (shortType == null) {
String ct = getContentType();
try {
MimeType mt = new MimeType(ct);
shortType = mt.getBaseType();
} catch (MimeTypeParseException e) {
shortType = ct;
}
}
return shortType;
}
/**
* Sets the DataContentHandlerFactory. The DataContentHandlerFactory
* is called first to find DataContentHandlers.
* The DataContentHandlerFactory can only be set once.
* <p>
* If the DataContentHandlerFactory has already been set,
* this method throws an Error.
*
* @param newFactory the DataContentHandlerFactory
* @exception Error if the factory has already been defined.
*
* @see javax.activation.DataContentHandlerFactory
*/
public static synchronized void setDataContentHandlerFactory(
DataContentHandlerFactory newFactory) {
if (factory != null)
throw new Error("DataContentHandlerFactory already defined");
SecurityManager security = System.getSecurityManager();
if (security != null) {
try {
// if it's ok with the SecurityManager, it's ok with me...
security.checkSetFactory();
} catch (SecurityException ex) {
// otherwise, we also allow it if this code and the
// factory come from the same class loader (e.g.,
// the JAF classes were loaded with the applet classes).
if (DataHandler.class.getClassLoader() !=
newFactory.getClass().getClassLoader())
throw ex;
}
}
factory = newFactory;
}
}
/**
* The DataHanderDataSource class implements the
* DataSource interface when the DataHandler is constructed
* with an Object and a mimeType string.
*/
class DataHandlerDataSource implements DataSource {
DataHandler dataHandler = null;
/**
* The constructor.
*/
public DataHandlerDataSource(DataHandler dh) {
this.dataHandler = dh;
}
/**
* Returns an {@code InputStream} representing this object.
* @return the {@code InputStream}
*/
public InputStream getInputStream() throws IOException {
return dataHandler.getInputStream();
}
/**
* Returns the {@code OutputStream} for this object.
* @return the {@code OutputStream}
*/
public OutputStream getOutputStream() throws IOException {
return dataHandler.getOutputStream();
}
/**
* Returns the MIME type of the data represented by this object.
* @return the MIME type
*/
public String getContentType() {
return dataHandler.getContentType();
}
/**
* Returns the name of this object.
* @return the name of this object
*/
public String getName() {
return dataHandler.getName(); // what else would it be?
}
}
/*
* DataSourceDataContentHandler
*
* This is a <i>private</i> DataContentHandler that wraps the real
* DataContentHandler in the case where the DataHandler was instantiated
* with a DataSource.
*/
class DataSourceDataContentHandler implements DataContentHandler {
private DataSource ds = null;
private DataFlavor transferFlavors[] = null;
private DataContentHandler dch = null;
/**
* The constructor.
*/
public DataSourceDataContentHandler(DataContentHandler dch, DataSource ds) {
this.ds = ds;
this.dch = dch;
}
/**
* Return the DataFlavors for this {@code DataContentHandler}.
* @return the DataFlavors
*/
public DataFlavor[] getTransferDataFlavors() {
if (transferFlavors == null) {
if (dch != null) { // is there a dch?
transferFlavors = dch.getTransferDataFlavors();
} else {
transferFlavors = new DataFlavor[1];
transferFlavors[0] =
new ActivationDataFlavor(ds.getContentType(),
ds.getContentType());
}
}
return transferFlavors;
}
/**
* Return the Transfer Data of type DataFlavor from InputStream.
* @param df the DataFlavor
* @param ds the DataSource
* @return the constructed Object
*/
public Object getTransferData(DataFlavor df, DataSource ds) throws
UnsupportedFlavorException, IOException {
if (dch != null)
return dch.getTransferData(df, ds);
else if (df.equals(getTransferDataFlavors()[0])) // only have one now
return ds.getInputStream();
else
throw new UnsupportedFlavorException(df);
}
public Object getContent(DataSource ds) throws IOException {
if (dch != null)
return dch.getContent(ds);
else
return ds.getInputStream();
}
/**
* Write the object to the output stream.
*/
public void writeTo(Object obj, String mimeType, OutputStream os)
throws IOException {
if (dch != null)
dch.writeTo(obj, mimeType, os);
else
throw new UnsupportedDataTypeException(
"no DCH for content type " + ds.getContentType());
}
}
/*
* ObjectDataContentHandler
*
* This is a <i>private</i> DataContentHandler that wraps the real
* DataContentHandler in the case where the DataHandler was instantiated
* with an object.
*/
class ObjectDataContentHandler implements DataContentHandler {
private DataFlavor transferFlavors[] = null;
private Object obj;
private String mimeType;
private DataContentHandler dch = null;
/**
* The constructor.
*/
public ObjectDataContentHandler(DataContentHandler dch,
Object obj, String mimeType) {
this.obj = obj;
this.mimeType = mimeType;
this.dch = dch;
}
/**
* Return the DataContentHandler for this object.
* Used only by the DataHandler class.
*/
public DataContentHandler getDCH() {
return dch;
}
/**
* Return the DataFlavors for this {@code DataContentHandler}.
* @return the DataFlavors
*/
public synchronized DataFlavor[] getTransferDataFlavors() {
if (transferFlavors == null) {
if (dch != null) {
transferFlavors = dch.getTransferDataFlavors();
} else {
transferFlavors = new DataFlavor[1];
transferFlavors[0] = new ActivationDataFlavor(obj.getClass(),
mimeType, mimeType);
}
}
return transferFlavors;
}
/**
* Return the Transfer Data of type DataFlavor from InputStream.
* @param df the DataFlavor
* @param ds the DataSource
* @return the constructed Object
*/
public Object getTransferData(DataFlavor df, DataSource ds)
throws UnsupportedFlavorException, IOException {
if (dch != null)
return dch.getTransferData(df, ds);
else if (df.equals(getTransferDataFlavors()[0])) // only have one now
return obj;
else
throw new UnsupportedFlavorException(df);
}
public Object getContent(DataSource ds) {
return obj;
}
/**
* Write the object to the output stream.
*/
public void writeTo(Object obj, String mimeType, OutputStream os)
throws IOException {
if (dch != null)
dch.writeTo(obj, mimeType, os);
else if (obj instanceof byte[])
os.write((byte[])obj);
else if (obj instanceof String) {
OutputStreamWriter osw = new OutputStreamWriter(os);
osw.write((String)obj);
osw.flush();
} else throw new UnsupportedDataTypeException(
"no object DCH for MIME type " + this.mimeType);
}
}

View file

@ -1,88 +0,0 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
/**
* The DataSource interface provides the JavaBeans Activation Framework
* with an abstraction of an arbitrary collection of data. It
* provides a type for that data as well as access
* to it in the form of <code>InputStreams</code> and
* <code>OutputStreams</code> where appropriate.
*
* @since 1.6
*/
public interface DataSource {
/**
* This method returns an <code>InputStream</code> representing
* the data and throws the appropriate exception if it can
* not do so. Note that a new <code>InputStream</code> object must be
* returned each time this method is called, and the stream must be
* positioned at the beginning of the data.
*
* @return an InputStream
* @exception IOException for failures creating the InputStream
*/
public InputStream getInputStream() throws IOException;
/**
* This method returns an <code>OutputStream</code> where the
* data can be written and throws the appropriate exception if it can
* not do so. Note that a new <code>OutputStream</code> object must
* be returned each time this method is called, and the stream must
* be positioned at the location the data is to be written.
*
* @return an OutputStream
* @exception IOException for failures creating the OutputStream
*/
public OutputStream getOutputStream() throws IOException;
/**
* This method returns the MIME type of the data in the form of a
* string. It should always return a valid type. It is suggested
* that getContentType return "application/octet-stream" if the
* DataSource implementation can not determine the data type.
*
* @return the MIME Type
*/
public String getContentType();
/**
* Return the <i>name</i> of this object where the name of the object
* is dependant on the nature of the underlying objects. DataSources
* encapsulating files may choose to return the filename of the object.
* (Typically this would be the last component of the filename, not an
* entire pathname.)
*
* @return the name of the object.
*/
public String getName();
}

View file

@ -1,158 +0,0 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileNotFoundException;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import com.sun.activation.registries.MimeTypeFile;
/**
* The FileDataSource class implements a simple DataSource object
* that encapsulates a file. It provides data typing services via
* a FileTypeMap object. <p>
*
* <b>FileDataSource Typing Semantics</b><p>
*
* The FileDataSource class delegates data typing of files
* to an object subclassed from the FileTypeMap class.
* The <code>setFileTypeMap</code> method can be used to explicitly
* set the FileTypeMap for an instance of FileDataSource. If no
* FileTypeMap is set, the FileDataSource will call the FileTypeMap's
* getDefaultFileTypeMap method to get the System's default FileTypeMap.
*
* @see javax.activation.DataSource
* @see javax.activation.FileTypeMap
* @see javax.activation.MimetypesFileTypeMap
*
* @since 1.6
*/
public class FileDataSource implements DataSource {
// keep track of original 'ref' passed in, non-null
// one indicated which was passed in:
private File _file = null;
private FileTypeMap typeMap = null;
/**
* Creates a FileDataSource from a File object. <i>Note:
* The file will not actually be opened until a method is
* called that requires the file to be opened.</i>
*
* @param file the file
*/
public FileDataSource(File file) {
_file = file; // save the file Object...
}
/**
* Creates a FileDataSource from
* the specified path name. <i>Note:
* The file will not actually be opened until a method is
* called that requires the file to be opened.</i>
*
* @param name the system-dependent file name.
*/
public FileDataSource(String name) {
this(new File(name)); // use the file constructor
}
/**
* This method will return an InputStream representing the
* the data and will throw an IOException if it can
* not do so. This method will return a new
* instance of InputStream with each invocation.
*
* @return an InputStream
*/
public InputStream getInputStream() throws IOException {
return new FileInputStream(_file);
}
/**
* This method will return an OutputStream representing the
* the data and will throw an IOException if it can
* not do so. This method will return a new instance of
* OutputStream with each invocation.
*
* @return an OutputStream
*/
public OutputStream getOutputStream() throws IOException {
return new FileOutputStream(_file);
}
/**
* This method returns the MIME type of the data in the form of a
* string. This method uses the currently installed FileTypeMap. If
* there is no FileTypeMap explictly set, the FileDataSource will
* call the <code>getDefaultFileTypeMap</code> method on
* FileTypeMap to acquire a default FileTypeMap. <i>Note: By
* default, the FileTypeMap used will be a MimetypesFileTypeMap.</i>
*
* @return the MIME Type
* @see javax.activation.FileTypeMap#getDefaultFileTypeMap
*/
public String getContentType() {
// check to see if the type map is null?
if (typeMap == null)
return FileTypeMap.getDefaultFileTypeMap().getContentType(_file);
else
return typeMap.getContentType(_file);
}
/**
* Return the <i>name</i> of this object. The FileDataSource
* will return the file name of the object.
*
* @return the name of the object.
* @see javax.activation.DataSource
*/
public String getName() {
return _file.getName();
}
/**
* Return the File object that corresponds to this FileDataSource.
* @return the File object for the file represented by this object.
*/
public File getFile() {
return _file;
}
/**
* Set the FileTypeMap to use with this FileDataSource
*
* @param map The FileTypeMap for this object.
*/
public void setFileTypeMap(FileTypeMap map) {
typeMap = map;
}
}

View file

@ -1,132 +0,0 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.io.File;
import java.util.Map;
import java.util.WeakHashMap;
/**
* The FileTypeMap is an abstract class that provides a data typing
* interface for files. Implementations of this class will
* implement the getContentType methods which will derive a content
* type from a file name or a File object. FileTypeMaps could use any
* scheme to determine the data type, from examining the file extension
* of a file (like the MimetypesFileTypeMap) to opening the file and
* trying to derive its type from the contents of the file. The
* FileDataSource class uses the default FileTypeMap (a MimetypesFileTypeMap
* unless changed) to determine the content type of files.
*
* @see javax.activation.FileTypeMap
* @see javax.activation.FileDataSource
* @see javax.activation.MimetypesFileTypeMap
*
* @since 1.6
*/
public abstract class FileTypeMap {
private static FileTypeMap defaultMap = null;
private static Map<ClassLoader,FileTypeMap> map =
new WeakHashMap<ClassLoader,FileTypeMap>();
/**
* The default constructor.
*/
public FileTypeMap() {
super();
}
/**
* Return the type of the file object. This method should
* always return a valid MIME type.
*
* @param file A file to be typed.
* @return The content type.
*/
abstract public String getContentType(File file);
/**
* Return the type of the file passed in. This method should
* always return a valid MIME type.
*
* @param filename the pathname of the file.
* @return The content type.
*/
abstract public String getContentType(String filename);
/**
* Sets the default FileTypeMap for the system. This instance
* will be returned to callers of getDefaultFileTypeMap.
*
* @param fileTypeMap The FileTypeMap.
* @exception SecurityException if the caller doesn't have permission
* to change the default
*/
public static synchronized void setDefaultFileTypeMap(FileTypeMap fileTypeMap) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
try {
// if it's ok with the SecurityManager, it's ok with me...
security.checkSetFactory();
} catch (SecurityException ex) {
// otherwise, we also allow it if this code and the
// factory come from the same (non-system) class loader (e.g.,
// the JAF classes were loaded with the applet classes).
ClassLoader cl = FileTypeMap.class.getClassLoader();
if (cl == null || cl.getParent() == null ||
cl != fileTypeMap.getClass().getClassLoader())
throw ex;
}
}
// remove any per-thread-context-class-loader FileTypeMap
map.remove(SecuritySupport.getContextClassLoader());
defaultMap = fileTypeMap;
}
/**
* Return the default FileTypeMap for the system.
* If setDefaultFileTypeMap was called, return
* that instance, otherwise return an instance of
* <code>MimetypesFileTypeMap</code>.
*
* @return The default FileTypeMap
* @see javax.activation.FileTypeMap#setDefaultFileTypeMap
*/
public static synchronized FileTypeMap getDefaultFileTypeMap() {
if (defaultMap != null)
return defaultMap;
// fetch per-thread-context-class-loader default
ClassLoader tccl = SecuritySupport.getContextClassLoader();
FileTypeMap def = map.get(tccl);
if (def == null) {
def = new MimetypesFileTypeMap();
map.put(tccl, def);
}
return def;
}
}

View file

@ -1,721 +0,0 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.util.*;
import java.io.*;
import java.net.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import com.sun.activation.registries.MailcapFile;
import com.sun.activation.registries.LogSupport;
/**
* MailcapCommandMap extends the CommandMap
* abstract class. It implements a CommandMap whose configuration
* is based on mailcap files
* (<A HREF="http://www.ietf.org/rfc/rfc1524.txt">RFC 1524</A>).
* The MailcapCommandMap can be configured both programmatically
* and via configuration files.
* <p>
* <b>Mailcap file search order:</b><p>
* The MailcapCommandMap looks in various places in the user's
* system for mailcap file entries. When requests are made
* to search for commands in the MailcapCommandMap, it searches
* mailcap files in the following order:
* <ol>
* <li> Programatically added entries to the MailcapCommandMap instance.
* <li> The file {@code .mailcap} in the user's home directory.
* <li> The file {@code mailcap} in the Java runtime.
* <li> The file or resources named {@code META-INF/mailcap}.
* <li> The file or resource named {@code META-INF/mailcap.default}
* (usually found only in the {@code activation.jar} file).
* </ol>
* <p>
* (The current implementation looks for the {@code mailcap} file
* in the Java runtime in the directory <i>java.home</i>{@code /conf}
* if it exists, and otherwise in the directory
* <i>java.home</i>{@code /lib}, where <i>java.home</i> is the value
* of the "java.home" System property. Note that the "conf" directory was
* introduced in JDK 9.)
* <p>
* <b>Mailcap file format:</b><p>
*
* Mailcap files must conform to the mailcap
* file specification (RFC 1524, <i>A User Agent Configuration Mechanism
* For Multimedia Mail Format Information</i>).
* The file format consists of entries corresponding to
* particular MIME types. In general, the specification
* specifies <i>applications</i> for clients to use when they
* themselves cannot operate on the specified MIME type. The
* MailcapCommandMap extends this specification by using a parameter mechanism
* in mailcap files that allows JavaBeans(tm) components to be specified as
* corresponding to particular commands for a MIME type.<p>
*
* When a mailcap file is
* parsed, the MailcapCommandMap recognizes certain parameter signatures,
* specifically those parameter names that begin with {@code x-java-}.
* The MailcapCommandMap uses this signature to find
* command entries for inclusion into its registries.
* Parameter names with the form {@code x-java-<name>}
* are read by the MailcapCommandMap as identifying a command
* with the name <i>name</i>. When the <i>name</i> is {@code
* content-handler} the MailcapCommandMap recognizes the class
* signified by this parameter as a <i>DataContentHandler</i>.
* All other commands are handled generically regardless of command
* name. The command implementation is specified by a fully qualified
* class name of a JavaBean(tm) component. For example; a command for viewing
* some data can be specified as: {@code x-java-view=com.foo.ViewBean}.<p>
*
* When the command name is {@code fallback-entry}, the value of
* the command may be {@code true} or {@code false}. An
* entry for a MIME type that includes a parameter of
* {@code x-java-fallback-entry=true} defines fallback commands
* for that MIME type that will only be used if no non-fallback entry
* can be found. For example, an entry of the form {@code text/*; ;
* x-java-fallback-entry=true; x-java-view=com.sun.TextViewer}
* specifies a view command to be used for any text MIME type. This
* view command would only be used if a non-fallback view command for
* the MIME type could not be found.<p>
*
* MailcapCommandMap aware mailcap files have the
* following general form:
* <pre>{@code
* # Comments begin with a '#' and continue to the end of the line.
* <mime type>; ; <parameter list>
* # Where a parameter list consists of one or more parameters,
* # where parameters look like: x-java-view=com.sun.TextViewer
* # and a parameter list looks like:
* text/plain; ; x-java-view=com.sun.TextViewer; x-java-edit=com.sun.TextEdit
* # Note that mailcap entries that do not contain 'x-java' parameters
* # and comply to RFC 1524 are simply ignored:
* image/gif; /usr/dt/bin/sdtimage %s
* }</pre>
*
* @author Bart Calder
* @author Bill Shannon
*
* @since 1.6
*/
public class MailcapCommandMap extends CommandMap {
/*
* We manage a collection of databases, searched in order.
*/
private MailcapFile[] DB;
private static final int PROG = 0; // programmatically added entries
private static final String confDir;
static {
String dir = null;
try {
dir = (String)AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
String home = System.getProperty("java.home");
String newdir = home + File.separator + "conf";
File conf = new File(newdir);
if (conf.exists())
return newdir + File.separator;
else
return home + File.separator + "lib" + File.separator;
}
});
} catch (Exception ex) {
// ignore any exceptions
}
confDir = dir;
}
/**
* The default Constructor.
*/
public MailcapCommandMap() {
super();
List dbv = new ArrayList(5); // usually 5 or less databases
MailcapFile mf = null;
dbv.add(null); // place holder for PROG entry
LogSupport.log("MailcapCommandMap: load HOME");
try {
String user_home = System.getProperty("user.home");
if (user_home != null) {
String path = user_home + File.separator + ".mailcap";
mf = loadFile(path);
if (mf != null)
dbv.add(mf);
}
} catch (SecurityException ex) {}
LogSupport.log("MailcapCommandMap: load SYS");
try {
// check system's home
if (confDir != null) {
mf = loadFile(confDir + "mailcap");
if (mf != null)
dbv.add(mf);
}
} catch (SecurityException ex) {}
LogSupport.log("MailcapCommandMap: load JAR");
// load from the app's jar file
loadAllResources(dbv, "META-INF/mailcap");
LogSupport.log("MailcapCommandMap: load DEF");
mf = loadResource("/META-INF/mailcap.default");
if (mf != null)
dbv.add(mf);
DB = new MailcapFile[dbv.size()];
DB = (MailcapFile[])dbv.toArray(DB);
}
/**
* Load from the named resource.
*/
private MailcapFile loadResource(String name) {
InputStream clis = null;
try {
clis = SecuritySupport.getResourceAsStream(this.getClass(), name);
if (clis != null) {
MailcapFile mf = new MailcapFile(clis);
if (LogSupport.isLoggable())
LogSupport.log("MailcapCommandMap: successfully loaded " +
"mailcap file: " + name);
return mf;
} else {
if (LogSupport.isLoggable())
LogSupport.log("MailcapCommandMap: not loading " +
"mailcap file: " + name);
}
} catch (IOException e) {
if (LogSupport.isLoggable())
LogSupport.log("MailcapCommandMap: can't load " + name, e);
} catch (SecurityException sex) {
if (LogSupport.isLoggable())
LogSupport.log("MailcapCommandMap: can't load " + name, sex);
} finally {
try {
if (clis != null)
clis.close();
} catch (IOException ex) { } // ignore it
}
return null;
}
/**
* Load all of the named resource.
*/
private void loadAllResources(List v, String name) {
boolean anyLoaded = false;
try {
URL[] urls;
ClassLoader cld = null;
// First try the "application's" class loader.
cld = SecuritySupport.getContextClassLoader();
if (cld == null)
cld = this.getClass().getClassLoader();
if (cld != null)
urls = SecuritySupport.getResources(cld, name);
else
urls = SecuritySupport.getSystemResources(name);
if (urls != null) {
if (LogSupport.isLoggable())
LogSupport.log("MailcapCommandMap: getResources");
for (int i = 0; i < urls.length; i++) {
URL url = urls[i];
InputStream clis = null;
if (LogSupport.isLoggable())
LogSupport.log("MailcapCommandMap: URL " + url);
try {
clis = SecuritySupport.openStream(url);
if (clis != null) {
v.add(new MailcapFile(clis));
anyLoaded = true;
if (LogSupport.isLoggable())
LogSupport.log("MailcapCommandMap: " +
"successfully loaded " +
"mailcap file from URL: " +
url);
} else {
if (LogSupport.isLoggable())
LogSupport.log("MailcapCommandMap: " +
"not loading mailcap " +
"file from URL: " + url);
}
} catch (IOException ioex) {
if (LogSupport.isLoggable())
LogSupport.log("MailcapCommandMap: can't load " +
url, ioex);
} catch (SecurityException sex) {
if (LogSupport.isLoggable())
LogSupport.log("MailcapCommandMap: can't load " +
url, sex);
} finally {
try {
if (clis != null)
clis.close();
} catch (IOException cex) { }
}
}
}
} catch (Exception ex) {
if (LogSupport.isLoggable())
LogSupport.log("MailcapCommandMap: can't load " + name, ex);
}
// if failed to load anything, fall back to old technique, just in case
if (!anyLoaded) {
if (LogSupport.isLoggable())
LogSupport.log("MailcapCommandMap: !anyLoaded");
MailcapFile mf = loadResource("/" + name);
if (mf != null)
v.add(mf);
}
}
/**
* Load from the named file.
*/
private MailcapFile loadFile(String name) {
MailcapFile mtf = null;
try {
mtf = new MailcapFile(name);
} catch (IOException e) {
// e.printStackTrace();
}
return mtf;
}
/**
* Constructor that allows the caller to specify the path
* of a <i>mailcap</i> file.
*
* @param fileName The name of the <i>mailcap</i> file to open
* @exception IOException if the file can't be accessed
*/
public MailcapCommandMap(String fileName) throws IOException {
this();
if (LogSupport.isLoggable())
LogSupport.log("MailcapCommandMap: load PROG from " + fileName);
if (DB[PROG] == null) {
DB[PROG] = new MailcapFile(fileName);
}
}
/**
* Constructor that allows the caller to specify an <i>InputStream</i>
* containing a mailcap file.
*
* @param is InputStream of the <i>mailcap</i> file to open
*/
public MailcapCommandMap(InputStream is) {
this();
LogSupport.log("MailcapCommandMap: load PROG");
if (DB[PROG] == null) {
try {
DB[PROG] = new MailcapFile(is);
} catch (IOException ex) {
// XXX - should throw it
}
}
}
/**
* Get the preferred command list for a MIME Type. The MailcapCommandMap
* searches the mailcap files as described above under
* <i>Mailcap file search order</i>.<p>
*
* The result of the search is a proper subset of available
* commands in all mailcap files known to this instance of
* MailcapCommandMap. The first entry for a particular command
* is considered the preferred command.
*
* @param mimeType the MIME type
* @return the CommandInfo objects representing the preferred commands.
*/
public synchronized CommandInfo[] getPreferredCommands(String mimeType) {
List cmdList = new ArrayList();
if (mimeType != null)
mimeType = mimeType.toLowerCase(Locale.ENGLISH);
for (int i = 0; i < DB.length; i++) {
if (DB[i] == null)
continue;
Map cmdMap = DB[i].getMailcapList(mimeType);
if (cmdMap != null)
appendPrefCmdsToList(cmdMap, cmdList);
}
// now add the fallback commands
for (int i = 0; i < DB.length; i++) {
if (DB[i] == null)
continue;
Map cmdMap = DB[i].getMailcapFallbackList(mimeType);
if (cmdMap != null)
appendPrefCmdsToList(cmdMap, cmdList);
}
CommandInfo[] cmdInfos = new CommandInfo[cmdList.size()];
cmdInfos = (CommandInfo[])cmdList.toArray(cmdInfos);
return cmdInfos;
}
/**
* Put the commands that are in the hash table, into the list.
*/
private void appendPrefCmdsToList(Map cmdHash, List cmdList) {
Iterator verb_enum = cmdHash.keySet().iterator();
while (verb_enum.hasNext()) {
String verb = (String)verb_enum.next();
if (!checkForVerb(cmdList, verb)) {
List cmdList2 = (List)cmdHash.get(verb); // get the list
String className = (String)cmdList2.get(0);
cmdList.add(new CommandInfo(verb, className));
}
}
}
/**
* Check the cmdList to see if this command exists, return
* true if the verb is there.
*/
private boolean checkForVerb(List cmdList, String verb) {
Iterator ee = cmdList.iterator();
while (ee.hasNext()) {
String enum_verb =
(String)((CommandInfo)ee.next()).getCommandName();
if (enum_verb.equals(verb))
return true;
}
return false;
}
/**
* Get all the available commands in all mailcap files known to
* this instance of MailcapCommandMap for this MIME type.
*
* @param mimeType the MIME type
* @return the CommandInfo objects representing all the commands.
*/
public synchronized CommandInfo[] getAllCommands(String mimeType) {
List cmdList = new ArrayList();
if (mimeType != null)
mimeType = mimeType.toLowerCase(Locale.ENGLISH);
for (int i = 0; i < DB.length; i++) {
if (DB[i] == null)
continue;
Map cmdMap = DB[i].getMailcapList(mimeType);
if (cmdMap != null)
appendCmdsToList(cmdMap, cmdList);
}
// now add the fallback commands
for (int i = 0; i < DB.length; i++) {
if (DB[i] == null)
continue;
Map cmdMap = DB[i].getMailcapFallbackList(mimeType);
if (cmdMap != null)
appendCmdsToList(cmdMap, cmdList);
}
CommandInfo[] cmdInfos = new CommandInfo[cmdList.size()];
cmdInfos = (CommandInfo[])cmdList.toArray(cmdInfos);
return cmdInfos;
}
/**
* Put the commands that are in the hash table, into the list.
*/
private void appendCmdsToList(Map typeHash, List cmdList) {
Iterator verb_enum = typeHash.keySet().iterator();
while (verb_enum.hasNext()) {
String verb = (String)verb_enum.next();
List cmdList2 = (List)typeHash.get(verb);
Iterator cmd_enum = ((List)cmdList2).iterator();
while (cmd_enum.hasNext()) {
String cmd = (String)cmd_enum.next();
cmdList.add(new CommandInfo(verb, cmd));
// cmdList.add(0, new CommandInfo(verb, cmd));
}
}
}
/**
* Get the command corresponding to {@code cmdName} for the MIME type.
*
* @param mimeType the MIME type
* @param cmdName the command name
* @return the CommandInfo object corresponding to the command.
*/
public synchronized CommandInfo getCommand(String mimeType,
String cmdName) {
if (mimeType != null)
mimeType = mimeType.toLowerCase(Locale.ENGLISH);
for (int i = 0; i < DB.length; i++) {
if (DB[i] == null)
continue;
Map cmdMap = DB[i].getMailcapList(mimeType);
if (cmdMap != null) {
// get the cmd list for the cmd
List v = (List)cmdMap.get(cmdName);
if (v != null) {
String cmdClassName = (String)v.get(0);
if (cmdClassName != null)
return new CommandInfo(cmdName, cmdClassName);
}
}
}
// now try the fallback list
for (int i = 0; i < DB.length; i++) {
if (DB[i] == null)
continue;
Map cmdMap = DB[i].getMailcapFallbackList(mimeType);
if (cmdMap != null) {
// get the cmd list for the cmd
List v = (List)cmdMap.get(cmdName);
if (v != null) {
String cmdClassName = (String)v.get(0);
if (cmdClassName != null)
return new CommandInfo(cmdName, cmdClassName);
}
}
}
return null;
}
/**
* Add entries to the registry. Programmatically
* added entries are searched before other entries.<p>
*
* The string that is passed in should be in mailcap
* format.
*
* @param mail_cap a correctly formatted mailcap string
*/
public synchronized void addMailcap(String mail_cap) {
// check to see if one exists
LogSupport.log("MailcapCommandMap: add to PROG");
if (DB[PROG] == null)
DB[PROG] = new MailcapFile();
DB[PROG].appendToMailcap(mail_cap);
}
/**
* Return the DataContentHandler for the specified MIME type.
*
* @param mimeType the MIME type
* @return the DataContentHandler
*/
public synchronized DataContentHandler createDataContentHandler(
String mimeType) {
if (LogSupport.isLoggable())
LogSupport.log(
"MailcapCommandMap: createDataContentHandler for " + mimeType);
if (mimeType != null)
mimeType = mimeType.toLowerCase(Locale.ENGLISH);
for (int i = 0; i < DB.length; i++) {
if (DB[i] == null)
continue;
if (LogSupport.isLoggable())
LogSupport.log(" search DB #" + i);
Map cmdMap = DB[i].getMailcapList(mimeType);
if (cmdMap != null) {
List v = (List)cmdMap.get("content-handler");
if (v != null) {
String name = (String)v.get(0);
DataContentHandler dch = getDataContentHandler(name);
if (dch != null)
return dch;
}
}
}
// now try the fallback entries
for (int i = 0; i < DB.length; i++) {
if (DB[i] == null)
continue;
if (LogSupport.isLoggable())
LogSupport.log(" search fallback DB #" + i);
Map cmdMap = DB[i].getMailcapFallbackList(mimeType);
if (cmdMap != null) {
List v = (List)cmdMap.get("content-handler");
if (v != null) {
String name = (String)v.get(0);
DataContentHandler dch = getDataContentHandler(name);
if (dch != null)
return dch;
}
}
}
return null;
}
private DataContentHandler getDataContentHandler(String name) {
if (LogSupport.isLoggable())
LogSupport.log(" got content-handler");
if (LogSupport.isLoggable())
LogSupport.log(" class " + name);
try {
ClassLoader cld = null;
// First try the "application's" class loader.
cld = SecuritySupport.getContextClassLoader();
if (cld == null)
cld = this.getClass().getClassLoader();
Class cl = null;
try {
cl = cld.loadClass(name);
} catch (Exception ex) {
// if anything goes wrong, do it the old way
cl = Class.forName(name);
}
return (DataContentHandler) cl.newInstance();
} catch (IllegalAccessException e) {
if (LogSupport.isLoggable())
LogSupport.log("Can't load DCH " + name, e);
} catch (ClassNotFoundException e) {
if (LogSupport.isLoggable())
LogSupport.log("Can't load DCH " + name, e);
} catch (InstantiationException e) {
if (LogSupport.isLoggable())
LogSupport.log("Can't load DCH " + name, e);
}
return null;
}
/**
* Get all the MIME types known to this command map.
*
* @return array of MIME types as strings
* @since 1.6, JAF 1.1
*/
public synchronized String[] getMimeTypes() {
List mtList = new ArrayList();
for (int i = 0; i < DB.length; i++) {
if (DB[i] == null)
continue;
String[] ts = DB[i].getMimeTypes();
if (ts != null) {
for (int j = 0; j < ts.length; j++) {
// eliminate duplicates
if (!mtList.contains(ts[j]))
mtList.add(ts[j]);
}
}
}
String[] mts = new String[mtList.size()];
mts = (String[])mtList.toArray(mts);
return mts;
}
/**
* Get the native commands for the given MIME type.
* Returns an array of strings where each string is
* an entire mailcap file entry. The application
* will need to parse the entry to extract the actual
* command as well as any attributes it needs. See
* <A HREF="http://www.ietf.org/rfc/rfc1524.txt">RFC 1524</A>
* for details of the mailcap entry syntax. Only mailcap
* entries that specify a view command for the specified
* MIME type are returned.
*
* @param mimeType the MIME type
* @return array of native command entries
* @since 1.6, JAF 1.1
*/
public synchronized String[] getNativeCommands(String mimeType) {
List cmdList = new ArrayList();
if (mimeType != null)
mimeType = mimeType.toLowerCase(Locale.ENGLISH);
for (int i = 0; i < DB.length; i++) {
if (DB[i] == null)
continue;
String[] cmds = DB[i].getNativeCommands(mimeType);
if (cmds != null) {
for (int j = 0; j < cmds.length; j++) {
// eliminate duplicates
if (!cmdList.contains(cmds[j]))
cmdList.add(cmds[j]);
}
}
}
String[] cmds = new String[cmdList.size()];
cmds = (String[])cmdList.toArray(cmds);
return cmds;
}
/**
* for debugging...
*
public static void main(String[] argv) throws Exception {
MailcapCommandMap map = new MailcapCommandMap();
CommandInfo[] cmdInfo;
cmdInfo = map.getPreferredCommands(argv[0]);
System.out.println("Preferred Commands:");
for (int i = 0; i < cmdInfo.length; i++)
System.out.println("Command " + cmdInfo[i].getCommandName() + " [" +
cmdInfo[i].getCommandClass() + "]");
cmdInfo = map.getAllCommands(argv[0]);
System.out.println();
System.out.println("All Commands:");
for (int i = 0; i < cmdInfo.length; i++)
System.out.println("Command " + cmdInfo[i].getCommandName() + " [" +
cmdInfo[i].getCommandClass() + "]");
DataContentHandler dch = map.createDataContentHandler(argv[0]);
if (dch != null)
System.out.println("DataContentHandler " +
dch.getClass().toString());
System.exit(0);
}
*/
}

View file

@ -1,346 +0,0 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.io.*;
import java.util.Locale;
/**
* A Multipurpose Internet Mail Extension (MIME) type, as defined
* in RFC 2045 and 2046.
*
* @since 1.6
*/
public class MimeType implements Externalizable {
private String primaryType;
private String subType;
private MimeTypeParameterList parameters;
/**
* A string that holds all the special chars.
*/
private static final String TSPECIALS = "()<>@,;:/[]?=\\\"";
/**
* Default constructor.
*/
public MimeType() {
primaryType = "application";
subType = "*";
parameters = new MimeTypeParameterList();
}
/**
* Constructor that builds a MimeType from a String.
*
* @param rawdata the MIME type string
* @exception MimeTypeParseException if the MIME type can't be parsed
*/
public MimeType(String rawdata) throws MimeTypeParseException {
parse(rawdata);
}
/**
* Constructor that builds a MimeType with the given primary and sub type
* but has an empty parameter list.
*
* @param primary the primary MIME type
* @param sub the MIME sub-type
* @exception MimeTypeParseException if the primary type or subtype
* is not a valid token
*/
public MimeType(String primary, String sub) throws MimeTypeParseException {
// check to see if primary is valid
if (isValidToken(primary)) {
primaryType = primary.toLowerCase(Locale.ENGLISH);
} else {
throw new MimeTypeParseException("Primary type is invalid.");
}
// check to see if sub is valid
if (isValidToken(sub)) {
subType = sub.toLowerCase(Locale.ENGLISH);
} else {
throw new MimeTypeParseException("Sub type is invalid.");
}
parameters = new MimeTypeParameterList();
}
/**
* A routine for parsing the MIME type out of a String.
*/
private void parse(String rawdata) throws MimeTypeParseException {
int slashIndex = rawdata.indexOf('/');
int semIndex = rawdata.indexOf(';');
if ((slashIndex < 0) && (semIndex < 0)) {
// neither character is present, so treat it
// as an error
throw new MimeTypeParseException("Unable to find a sub type.");
} else if ((slashIndex < 0) && (semIndex >= 0)) {
// we have a ';' (and therefore a parameter list),
// but no '/' indicating a sub type is present
throw new MimeTypeParseException("Unable to find a sub type.");
} else if ((slashIndex >= 0) && (semIndex < 0)) {
// we have a primary and sub type but no parameter list
primaryType = rawdata.substring(0, slashIndex).trim().
toLowerCase(Locale.ENGLISH);
subType = rawdata.substring(slashIndex + 1).trim().
toLowerCase(Locale.ENGLISH);
parameters = new MimeTypeParameterList();
} else if (slashIndex < semIndex) {
// we have all three items in the proper sequence
primaryType = rawdata.substring(0, slashIndex).trim().
toLowerCase(Locale.ENGLISH);
subType = rawdata.substring(slashIndex + 1, semIndex).trim().
toLowerCase(Locale.ENGLISH);
parameters = new MimeTypeParameterList(rawdata.substring(semIndex));
} else {
// we have a ';' lexically before a '/' which means we
// have a primary type and a parameter list but no sub type
throw new MimeTypeParseException("Unable to find a sub type.");
}
// now validate the primary and sub types
// check to see if primary is valid
if (!isValidToken(primaryType))
throw new MimeTypeParseException("Primary type is invalid.");
// check to see if sub is valid
if (!isValidToken(subType))
throw new MimeTypeParseException("Sub type is invalid.");
}
/**
* Retrieve the primary type of this object.
*
* @return the primary MIME type
*/
public String getPrimaryType() {
return primaryType;
}
/**
* Set the primary type for this object to the given String.
*
* @param primary the primary MIME type
* @exception MimeTypeParseException if the primary type
* is not a valid token
*/
public void setPrimaryType(String primary) throws MimeTypeParseException {
// check to see if primary is valid
if (!isValidToken(primaryType))
throw new MimeTypeParseException("Primary type is invalid.");
primaryType = primary.toLowerCase(Locale.ENGLISH);
}
/**
* Retrieve the subtype of this object.
*
* @return the MIME subtype
*/
public String getSubType() {
return subType;
}
/**
* Set the subtype for this object to the given String.
*
* @param sub the MIME subtype
* @exception MimeTypeParseException if the subtype
* is not a valid token
*/
public void setSubType(String sub) throws MimeTypeParseException {
// check to see if sub is valid
if (!isValidToken(subType))
throw new MimeTypeParseException("Sub type is invalid.");
subType = sub.toLowerCase(Locale.ENGLISH);
}
/**
* Retrieve this object's parameter list.
*
* @return a MimeTypeParameterList object representing the parameters
*/
public MimeTypeParameterList getParameters() {
return parameters;
}
/**
* Retrieve the value associated with the given name, or null if there
* is no current association.
*
* @param name the parameter name
* @return the paramter's value
*/
public String getParameter(String name) {
return parameters.get(name);
}
/**
* Set the value to be associated with the given name, replacing
* any previous association.
*
* @param name the parameter name
* @param value the paramter's value
*/
public void setParameter(String name, String value) {
parameters.set(name, value);
}
/**
* Remove any value associated with the given name.
*
* @param name the parameter name
*/
public void removeParameter(String name) {
parameters.remove(name);
}
/**
* Return the String representation of this object.
*/
public String toString() {
return getBaseType() + parameters.toString();
}
/**
* Return a String representation of this object
* without the parameter list.
*
* @return the MIME type and sub-type
*/
public String getBaseType() {
return primaryType + "/" + subType;
}
/**
* Determine if the primary and sub type of this object is
* the same as what is in the given type.
*
* @param type the MimeType object to compare with
* @return true if they match
*/
public boolean match(MimeType type) {
return primaryType.equals(type.getPrimaryType())
&& (subType.equals("*")
|| type.getSubType().equals("*")
|| (subType.equals(type.getSubType())));
}
/**
* Determine if the primary and sub type of this object is
* the same as the content type described in rawdata.
*
* @param rawdata the MIME type string to compare with
* @return true if they match
* @exception MimeTypeParseException if the MIME type can't be parsed
*/
public boolean match(String rawdata) throws MimeTypeParseException {
return match(new MimeType(rawdata));
}
/**
* The object implements the writeExternal method to save its contents
* by calling the methods of DataOutput for its primitive values or
* calling the writeObject method of ObjectOutput for objects, strings
* and arrays.
*
* @param out the ObjectOutput object to write to
* @exception IOException Includes any I/O exceptions that may occur
*/
public void writeExternal(ObjectOutput out) throws IOException {
out.writeUTF(toString());
out.flush();
}
/**
* The object implements the readExternal method to restore its
* contents by calling the methods of DataInput for primitive
* types and readObject for objects, strings and arrays. The
* readExternal method must read the values in the same sequence
* and with the same types as were written by writeExternal.
*
* @param in the ObjectInput object to read from
* @exception ClassNotFoundException If the class for an object being
* restored cannot be found.
*/
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
try {
parse(in.readUTF());
} catch (MimeTypeParseException e) {
throw new IOException(e.toString());
}
}
// below here be scary parsing related things
/**
* Determine whether or not a given character belongs to a legal token.
*/
private static boolean isTokenChar(char c) {
return ((c > 040) && (c < 0177)) && (TSPECIALS.indexOf(c) < 0);
}
/**
* Determine whether or not a given string is a legal token.
*/
private boolean isValidToken(String s) {
int len = s.length();
if (len > 0) {
for (int i = 0; i < len; ++i) {
char c = s.charAt(i);
if (!isTokenChar(c)) {
return false;
}
}
return true;
} else {
return false;
}
}
/**
* A simple parser test,
* for debugging...
*
public static void main(String[] args)
throws MimeTypeParseException, IOException {
for (int i = 0; i < args.length; ++i) {
System.out.println("Original: " + args[i]);
MimeType type = new MimeType(args[i]);
System.out.println("Short: " + type.getBaseType());
System.out.println("Parsed: " + type.toString());
System.out.println();
}
}
*/
}

View file

@ -1,341 +0,0 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Locale;
/**
* A parameter list of a MimeType
* as defined in RFC 2045 and 2046. The Primary type of the
* object must already be stripped off.
*
* @see javax.activation.MimeType
*
* @since 1.6
*/
public class MimeTypeParameterList {
private Hashtable parameters;
/**
* A string that holds all the special chars.
*/
private static final String TSPECIALS = "()<>@,;:/[]?=\\\"";
/**
* Default constructor.
*/
public MimeTypeParameterList() {
parameters = new Hashtable();
}
/**
* Constructs a new MimeTypeParameterList with the passed in data.
*
* @param parameterList an RFC 2045, 2046 compliant parameter list.
* @exception MimeTypeParseException if the MIME type can't be parsed
*/
public MimeTypeParameterList(String parameterList)
throws MimeTypeParseException {
parameters = new Hashtable();
// now parse rawdata
parse(parameterList);
}
/**
* A routine for parsing the parameter list out of a String.
*
* @param parameterList an RFC 2045, 2046 compliant parameter list.
* @exception MimeTypeParseException if the MIME type can't be parsed
*/
protected void parse(String parameterList) throws MimeTypeParseException {
if (parameterList == null)
return;
int length = parameterList.length();
if (length <= 0)
return;
int i;
char c;
for (i = skipWhiteSpace(parameterList, 0);
i < length && (c = parameterList.charAt(i)) == ';';
i = skipWhiteSpace(parameterList, i)) {
int lastIndex;
String name;
String value;
// eat the ';'
i++;
// now parse the parameter name
// skip whitespace
i = skipWhiteSpace(parameterList, i);
// tolerate trailing semicolon, even though it violates the spec
if (i >= length)
return;
// find the end of the token char run
lastIndex = i;
while ((i < length) && isTokenChar(parameterList.charAt(i)))
i++;
name = parameterList.substring(lastIndex, i).
toLowerCase(Locale.ENGLISH);
// now parse the '=' that separates the name from the value
i = skipWhiteSpace(parameterList, i);
if (i >= length || parameterList.charAt(i) != '=')
throw new MimeTypeParseException(
"Couldn't find the '=' that separates a " +
"parameter name from its value.");
// eat it and parse the parameter value
i++;
i = skipWhiteSpace(parameterList, i);
if (i >= length)
throw new MimeTypeParseException(
"Couldn't find a value for parameter named " + name);
// now find out whether or not we have a quoted value
c = parameterList.charAt(i);
if (c == '"') {
// yup it's quoted so eat it and capture the quoted string
i++;
if (i >= length)
throw new MimeTypeParseException(
"Encountered unterminated quoted parameter value.");
lastIndex = i;
// find the next unescaped quote
while (i < length) {
c = parameterList.charAt(i);
if (c == '"')
break;
if (c == '\\') {
// found an escape sequence
// so skip this and the
// next character
i++;
}
i++;
}
if (c != '"')
throw new MimeTypeParseException(
"Encountered unterminated quoted parameter value.");
value = unquote(parameterList.substring(lastIndex, i));
// eat the quote
i++;
} else if (isTokenChar(c)) {
// nope it's an ordinary token so it
// ends with a non-token char
lastIndex = i;
while (i < length && isTokenChar(parameterList.charAt(i)))
i++;
value = parameterList.substring(lastIndex, i);
} else {
// it ain't a value
throw new MimeTypeParseException(
"Unexpected character encountered at index " + i);
}
// now put the data into the hashtable
parameters.put(name, value);
}
if (i < length) {
throw new MimeTypeParseException(
"More characters encountered in input than expected.");
}
}
/**
* Return the number of name-value pairs in this list.
*
* @return the number of parameters
*/
public int size() {
return parameters.size();
}
/**
* Determine whether or not this list is empty.
*
* @return true if there are no parameters
*/
public boolean isEmpty() {
return parameters.isEmpty();
}
/**
* Retrieve the value associated with the given name, or null if there
* is no current association.
*
* @param name the parameter name
* @return the parameter's value
*/
public String get(String name) {
return (String)parameters.get(name.trim().toLowerCase(Locale.ENGLISH));
}
/**
* Set the value to be associated with the given name, replacing
* any previous association.
*
* @param name the parameter name
* @param value the parameter's value
*/
public void set(String name, String value) {
parameters.put(name.trim().toLowerCase(Locale.ENGLISH), value);
}
/**
* Remove any value associated with the given name.
*
* @param name the parameter name
*/
public void remove(String name) {
parameters.remove(name.trim().toLowerCase(Locale.ENGLISH));
}
/**
* Retrieve an enumeration of all the names in this list.
*
* @return an enumeration of all parameter names
*/
public Enumeration getNames() {
return parameters.keys();
}
/**
* Return a string representation of this object.
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.ensureCapacity(parameters.size() * 16);
// heuristic: 8 characters per field
Enumeration keys = parameters.keys();
while (keys.hasMoreElements()) {
String key = (String)keys.nextElement();
buffer.append("; ");
buffer.append(key);
buffer.append('=');
buffer.append(quote((String)parameters.get(key)));
}
return buffer.toString();
}
// below here be scary parsing related things
/**
* Determine whether or not a given character belongs to a legal token.
*/
private static boolean isTokenChar(char c) {
return ((c > 040) && (c < 0177)) && (TSPECIALS.indexOf(c) < 0);
}
/**
* return the index of the first non white space character in
* rawdata at or after index i.
*/
private static int skipWhiteSpace(String rawdata, int i) {
int length = rawdata.length();
while ((i < length) && Character.isWhitespace(rawdata.charAt(i)))
i++;
return i;
}
/**
* A routine that knows how and when to quote and escape the given value.
*/
private static String quote(String value) {
boolean needsQuotes = false;
// check to see if we actually have to quote this thing
int length = value.length();
for (int i = 0; (i < length) && !needsQuotes; i++) {
needsQuotes = !isTokenChar(value.charAt(i));
}
if (needsQuotes) {
StringBuffer buffer = new StringBuffer();
buffer.ensureCapacity((int)(length * 1.5));
// add the initial quote
buffer.append('"');
// add the properly escaped text
for (int i = 0; i < length; ++i) {
char c = value.charAt(i);
if ((c == '\\') || (c == '"'))
buffer.append('\\');
buffer.append(c);
}
// add the closing quote
buffer.append('"');
return buffer.toString();
} else {
return value;
}
}
/**
* A routine that knows how to strip the quotes and
* escape sequences from the given value.
*/
private static String unquote(String value) {
int valueLength = value.length();
StringBuffer buffer = new StringBuffer();
buffer.ensureCapacity(valueLength);
boolean escaped = false;
for (int i = 0; i < valueLength; ++i) {
char currentChar = value.charAt(i);
if (!escaped && (currentChar != '\\')) {
buffer.append(currentChar);
} else if (escaped) {
buffer.append(currentChar);
escaped = false;
} else {
escaped = true;
}
}
return buffer.toString();
}
}

View file

@ -1,50 +0,0 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
/**
* A class to encapsulate MimeType parsing related exceptions.
*
* @since 1.6
*/
public class MimeTypeParseException extends Exception {
/**
* Constructs a MimeTypeParseException with no specified detail message.
*/
public MimeTypeParseException() {
super();
}
/**
* Constructs a MimeTypeParseException with the specified detail message.
*
* @param s the detail message.
*/
public MimeTypeParseException(String s) {
super(s);
}
}

View file

@ -1,360 +0,0 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.io.*;
import java.net.*;
import java.util.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import com.sun.activation.registries.MimeTypeFile;
import com.sun.activation.registries.LogSupport;
/**
* This class extends FileTypeMap and provides data typing of files
* via their file extension. It uses the {@code .mime.types} format. <p>
*
* <b>MIME types file search order:</b><p>
* The MimetypesFileTypeMap looks in various places in the user's
* system for MIME types file entries. When requests are made
* to search for MIME types in the MimetypesFileTypeMap, it searches
* MIME types files in the following order:
* <ol>
* <li> Programmatically added entries to the MimetypesFileTypeMap instance.
* <li> The file {@code .mime.types} in the user's home directory.
* <li> The file {@code mime.types} in the Java runtime.
* <li> The file or resources named {@code META-INF/mime.types}.
* <li> The file or resource named {@code META-INF/mimetypes.default}
* (usually found only in the {@code activation.jar} file).
* </ol>
* <p>
* (The current implementation looks for the {@code mime.types} file
* in the Java runtime in the directory <i>java.home</i>{@code /conf}
* if it exists, and otherwise in the directory
* <i>java.home</i>{@code /lib}, where <i>java.home</i> is the value
* of the "java.home" System property. Note that the "conf" directory was
* introduced in JDK 9.)
* <p>
* <b>MIME types file format:</b>
*
* <pre>{@code
* # comments begin with a '#'
* # the format is <mime type> <space separated file extensions>
* # for example:
* text/plain txt text TXT
* # this would map file.txt, file.text, and file.TXT to
* # the mime type "text/plain"
* }</pre>
*
* @author Bart Calder
* @author Bill Shannon
*
* @since 1.6
*/
public class MimetypesFileTypeMap extends FileTypeMap {
/*
* We manage a collection of databases, searched in order.
*/
private MimeTypeFile[] DB;
private static final int PROG = 0; // programmatically added entries
private static final String defaultType = "application/octet-stream";
private static final String confDir;
static {
String dir = null;
try {
dir = (String)AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
String home = System.getProperty("java.home");
String newdir = home + File.separator + "conf";
File conf = new File(newdir);
if (conf.exists())
return newdir + File.separator;
else
return home + File.separator + "lib" + File.separator;
}
});
} catch (Exception ex) {
// ignore any exceptions
}
confDir = dir;
}
/**
* The default constructor.
*/
public MimetypesFileTypeMap() {
Vector dbv = new Vector(5); // usually 5 or less databases
MimeTypeFile mf = null;
dbv.addElement(null); // place holder for PROG entry
LogSupport.log("MimetypesFileTypeMap: load HOME");
try {
String user_home = System.getProperty("user.home");
if (user_home != null) {
String path = user_home + File.separator + ".mime.types";
mf = loadFile(path);
if (mf != null)
dbv.addElement(mf);
}
} catch (SecurityException ex) {}
LogSupport.log("MimetypesFileTypeMap: load SYS");
try {
// check system's home
if (confDir != null) {
mf = loadFile(confDir + "mime.types");
if (mf != null)
dbv.addElement(mf);
}
} catch (SecurityException ex) {}
LogSupport.log("MimetypesFileTypeMap: load JAR");
// load from the app's jar file
loadAllResources(dbv, "META-INF/mime.types");
LogSupport.log("MimetypesFileTypeMap: load DEF");
mf = loadResource("/META-INF/mimetypes.default");
if (mf != null)
dbv.addElement(mf);
DB = new MimeTypeFile[dbv.size()];
dbv.copyInto(DB);
}
/**
* Load from the named resource.
*/
private MimeTypeFile loadResource(String name) {
InputStream clis = null;
try {
clis = SecuritySupport.getResourceAsStream(this.getClass(), name);
if (clis != null) {
MimeTypeFile mf = new MimeTypeFile(clis);
if (LogSupport.isLoggable())
LogSupport.log("MimetypesFileTypeMap: successfully " +
"loaded mime types file: " + name);
return mf;
} else {
if (LogSupport.isLoggable())
LogSupport.log("MimetypesFileTypeMap: not loading " +
"mime types file: " + name);
}
} catch (IOException e) {
if (LogSupport.isLoggable())
LogSupport.log("MimetypesFileTypeMap: can't load " + name, e);
} catch (SecurityException sex) {
if (LogSupport.isLoggable())
LogSupport.log("MimetypesFileTypeMap: can't load " + name, sex);
} finally {
try {
if (clis != null)
clis.close();
} catch (IOException ex) { } // ignore it
}
return null;
}
/**
* Load all of the named resource.
*/
private void loadAllResources(Vector v, String name) {
boolean anyLoaded = false;
try {
URL[] urls;
ClassLoader cld = null;
// First try the "application's" class loader.
cld = SecuritySupport.getContextClassLoader();
if (cld == null)
cld = this.getClass().getClassLoader();
if (cld != null)
urls = SecuritySupport.getResources(cld, name);
else
urls = SecuritySupport.getSystemResources(name);
if (urls != null) {
if (LogSupport.isLoggable())
LogSupport.log("MimetypesFileTypeMap: getResources");
for (int i = 0; i < urls.length; i++) {
URL url = urls[i];
InputStream clis = null;
if (LogSupport.isLoggable())
LogSupport.log("MimetypesFileTypeMap: URL " + url);
try {
clis = SecuritySupport.openStream(url);
if (clis != null) {
v.addElement(new MimeTypeFile(clis));
anyLoaded = true;
if (LogSupport.isLoggable())
LogSupport.log("MimetypesFileTypeMap: " +
"successfully loaded " +
"mime types from URL: " + url);
} else {
if (LogSupport.isLoggable())
LogSupport.log("MimetypesFileTypeMap: " +
"not loading " +
"mime types from URL: " + url);
}
} catch (IOException ioex) {
if (LogSupport.isLoggable())
LogSupport.log("MimetypesFileTypeMap: can't load " +
url, ioex);
} catch (SecurityException sex) {
if (LogSupport.isLoggable())
LogSupport.log("MimetypesFileTypeMap: can't load " +
url, sex);
} finally {
try {
if (clis != null)
clis.close();
} catch (IOException cex) { }
}
}
}
} catch (Exception ex) {
if (LogSupport.isLoggable())
LogSupport.log("MimetypesFileTypeMap: can't load " + name, ex);
}
// if failed to load anything, fall back to old technique, just in case
if (!anyLoaded) {
LogSupport.log("MimetypesFileTypeMap: !anyLoaded");
MimeTypeFile mf = loadResource("/" + name);
if (mf != null)
v.addElement(mf);
}
}
/**
* Load the named file.
*/
private MimeTypeFile loadFile(String name) {
MimeTypeFile mtf = null;
try {
mtf = new MimeTypeFile(name);
} catch (IOException e) {
// e.printStackTrace();
}
return mtf;
}
/**
* Construct a MimetypesFileTypeMap with programmatic entries
* added from the named file.
*
* @param mimeTypeFileName the file name
* @exception IOException for errors reading the file
*/
public MimetypesFileTypeMap(String mimeTypeFileName) throws IOException {
this();
DB[PROG] = new MimeTypeFile(mimeTypeFileName);
}
/**
* Construct a MimetypesFileTypeMap with programmatic entries
* added from the InputStream.
*
* @param is the input stream to read from
*/
public MimetypesFileTypeMap(InputStream is) {
this();
try {
DB[PROG] = new MimeTypeFile(is);
} catch (IOException ex) {
// XXX - really should throw it
}
}
/**
* Prepend the MIME type values to the registry.
*
* @param mime_types A .mime.types formatted string of entries.
*/
public synchronized void addMimeTypes(String mime_types) {
// check to see if we have created the registry
if (DB[PROG] == null)
DB[PROG] = new MimeTypeFile(); // make one
DB[PROG].appendToRegistry(mime_types);
}
/**
* Return the MIME type of the file object.
* The implementation in this class calls
* {@code getContentType(f.getName())}.
*
* @param f the file
* @return the file's MIME type
*/
public String getContentType(File f) {
return this.getContentType(f.getName());
}
/**
* Return the MIME type based on the specified file name.
* The MIME type entries are searched as described above under
* <i>MIME types file search order</i>.
* If no entry is found, the type "application/octet-stream" is returned.
*
* @param filename the file name
* @return the file's MIME type
*/
public synchronized String getContentType(String filename) {
int dot_pos = filename.lastIndexOf("."); // period index
if (dot_pos < 0)
return defaultType;
String file_ext = filename.substring(dot_pos + 1);
if (file_ext.length() == 0)
return defaultType;
for (int i = 0; i < DB.length; i++) {
if (DB[i] == null)
continue;
String result = DB[i].getMIMETypeString(file_ext);
if (result != null)
return result;
}
return defaultType;
}
/**
* for debugging...
*
public static void main(String[] argv) throws Exception {
MimetypesFileTypeMap map = new MimetypesFileTypeMap();
System.out.println("File " + argv[0] + " has MIME type " +
map.getContentType(argv[0]));
System.exit(0);
}
*/
}

View file

@ -1,131 +0,0 @@
/*
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.security.*;
import java.net.*;
import java.io.*;
import java.util.*;
/**
* Security related methods that only work on J2SE 1.2 and newer.
*
* @since 1.6
*/
class SecuritySupport {
private SecuritySupport() {
// private constructor, can't create an instance
}
public static ClassLoader getContextClassLoader() {
return (ClassLoader)
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
ClassLoader cl = null;
try {
cl = Thread.currentThread().getContextClassLoader();
} catch (SecurityException ex) { }
return cl;
}
});
}
public static InputStream getResourceAsStream(final Class c,
final String name) throws IOException {
try {
return (InputStream)
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws IOException {
return c.getResourceAsStream(name);
}
});
} catch (PrivilegedActionException e) {
throw (IOException)e.getException();
}
}
public static URL[] getResources(final ClassLoader cl, final String name) {
return (URL[])
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
URL[] ret = null;
try {
List v = new ArrayList();
Enumeration e = cl.getResources(name);
while (e != null && e.hasMoreElements()) {
URL url = (URL)e.nextElement();
if (url != null)
v.add(url);
}
if (v.size() > 0) {
ret = new URL[v.size()];
ret = (URL[])v.toArray(ret);
}
} catch (IOException ioex) {
} catch (SecurityException ex) { }
return ret;
}
});
}
public static URL[] getSystemResources(final String name) {
return (URL[])
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
URL[] ret = null;
try {
List v = new ArrayList();
Enumeration e = ClassLoader.getSystemResources(name);
while (e != null && e.hasMoreElements()) {
URL url = (URL)e.nextElement();
if (url != null)
v.add(url);
}
if (v.size() > 0) {
ret = new URL[v.size()];
ret = (URL[])v.toArray(ret);
}
} catch (IOException ioex) {
} catch (SecurityException ex) { }
return ret;
}
});
}
public static InputStream openStream(final URL url) throws IOException {
try {
return (InputStream)
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws IOException {
return url.openStream();
}
});
} catch (PrivilegedActionException e) {
throw (IOException)e.getException();
}
}
}

View file

@ -1,137 +0,0 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.net.URL;
import java.net.URLConnection;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
/**
* The URLDataSource class provides an object that wraps a <code>URL</code>
* object in a DataSource interface. URLDataSource simplifies the handling
* of data described by URLs within the JavaBeans Activation Framework
* because this class can be used to create new DataHandlers. <i>NOTE: The
* DataHandler object creates a URLDataSource internally,
* when it is constructed with a URL.</i>
*
* @see javax.activation.DataSource
* @see javax.activation.DataHandler
*
* @since 1.6
*/
public class URLDataSource implements DataSource {
private URL url = null;
private URLConnection url_conn = null;
/**
* URLDataSource constructor. The URLDataSource class will
* not open a connection to the URL until a method requiring it
* to do so is called.
*
* @param url The URL to be encapsulated in this object.
*/
public URLDataSource(URL url) {
this.url = url;
}
/**
* Returns the value of the URL content-type header field.
* It calls the URL's <code>URLConnection.getContentType</code> method
* after retrieving a URLConnection object.
* <i>Note: this method attempts to call the <code>openConnection</code>
* method on the URL. If this method fails, or if a content type is not
* returned from the URLConnection, getContentType returns
* "application/octet-stream" as the content type.</i>
*
* @return the content type.
*/
public String getContentType() {
String type = null;
try {
if (url_conn == null)
url_conn = url.openConnection();
} catch (IOException e) { }
if (url_conn != null)
type = url_conn.getContentType();
if (type == null)
type = "application/octet-stream";
return type;
}
/**
* Calls the <code>getFile</code> method on the URL used to
* instantiate the object.
*
* @return the result of calling the URL's getFile method.
*/
public String getName() {
return url.getFile();
}
/**
* The getInputStream method from the URL. Calls the
* <code>openStream</code> method on the URL.
*
* @return the InputStream.
*/
public InputStream getInputStream() throws IOException {
return url.openStream();
}
/**
* The getOutputStream method from the URL. First an attempt is
* made to get the URLConnection object for the URL. If that
* succeeds, the getOutputStream method on the URLConnection
* is returned.
*
* @return the OutputStream.
*/
public OutputStream getOutputStream() throws IOException {
// get the url connection if it is available
url_conn = url.openConnection();
if (url_conn != null) {
url_conn.setDoOutput(true);
return url_conn.getOutputStream();
} else
return null;
}
/**
* Return the URL used to create this DataSource.
*
* @return The URL.
*/
public URL getURL() {
return url;
}
}

View file

@ -1,57 +0,0 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.activation;
import java.io.IOException;
/**
* Signals that the requested operation does not support the
* requested data type.
*
* @see javax.activation.DataHandler
*
* @since 1.6
*/
public class UnsupportedDataTypeException extends IOException {
/**
* Constructs an UnsupportedDataTypeException with no detail
* message.
*/
public UnsupportedDataTypeException() {
super();
}
/**
* Constructs an UnsupportedDataTypeException with the specified
* message.
*
* @param s The detail message.
*/
public UnsupportedDataTypeException(String s) {
super(s);
}
}

View file

@ -1,42 +0,0 @@
/*
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Defines the JavaBeans Activation Framework (JAF) API.
*
* <p> This module is upgradeable.
*
* @moduleGraph
* @since 9
*/
@Deprecated(since="9", forRemoval=true)
module java.activation {
requires java.logging;
requires transitive java.datatransfer;
exports javax.activation;
}

View file

@ -8,17 +8,11 @@
// ${java.home}/conf/security/java.policy.
//
grant codeBase "jrt:/java.activation" {
permission java.security.AllPermission;
};
grant codeBase "jrt:/java.compiler" {
permission java.security.AllPermission;
};
grant codeBase "jrt:/java.corba" {
permission java.security.AllPermission;
};
grant codeBase "jrt:/java.scripting" {
permission java.security.AllPermission;
@ -65,9 +59,6 @@ grant codeBase "jrt:/java.sql.rowset" {
permission java.security.AllPermission;
};
grant codeBase "jrt:/java.xml.bind" {
permission java.security.AllPermission;
};
grant codeBase "jrt:/java.xml.crypto" {
permission java.lang.RuntimePermission
@ -90,9 +81,6 @@ grant codeBase "jrt:/java.xml.crypto" {
"accessClassInPackage.com.sun.org.apache.xpath.internal.*";
};
grant codeBase "jrt:/java.xml.ws" {
permission java.security.AllPermission;
};
grant codeBase "jrt:/jdk.accessibility" {
permission java.lang.RuntimePermission "accessClassInPackage.sun.awt";

View file

@ -1,224 +0,0 @@
/*
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "IOP.idl"
module GIOP { // IDL extended for version 1.1 and 1.2
struct Version {
octet major;
octet minor;
};
// GIOP 1.0
struct MessageHeader_1_0 { // Renamed from MessageHeader
char magic [4];
Version GIOP_version;
boolean byte_order;
octet message_type;
unsigned long message_size;
};
// GIOP 1.1
struct MessageHeader_1_1 {
char magic [4];
Version GIOP_version;
octet flags; // GIOP 1.1 change
octet message_type;
unsigned long message_size;
};
// GIOP 1.2
// Same Header contents for 1.1 and 1.2
typedef MessageHeader_1_1 MessageHeader_1_2;
// GIOP 1.0
struct RequestHeader_1_0 { // Renamed from RequestHeader
IOP::ServiceContextList service_context;
unsigned long request_id;
boolean response_expected;
sequence<octet> object_key;
string operation;
sequence<octet> requesting_principal;
};
// GIOP 1.1
struct RequestHeader_1_1 {
IOP::ServiceContextList service_context;
unsigned long request_id;
boolean response_expected;
octet reserved[3]; // Added in GIOP 1.1
sequence <octet> object_key;
string operation;
sequence<octet> requesting_principal;
};
// GIOP 1.2
typedef short AddressingDisposition;
const short KeyAddr = 0;
const short ProfileAddr = 1;
const short ReferenceAddr = 2;
struct IORAddressingInfo {
unsigned long selected_profile_index;
IOP::IOR ior;
};
union TargetAddress switch (AddressingDisposition) {
case KeyAddr: sequence <octet> object_key;
case ProfileAddr: IOP::TaggedProfile profile;
case ReferenceAddr: IORAddressingInfo ior;
};
struct RequestHeader_1_2 {
unsigned long request_id;
octet response_flags;
octet reserved[3];
TargetAddress target;
string operation;
IOP::ServiceContextList service_context;
// Principal not in GIOP 1.2
};
#ifndef GIOP_1_2 //We're supporting all versions
// GIOP 1.0 and 1.1
enum ReplyStatusType_1_0 { // Renamed from ReplyStatusType
NO_EXCEPTION,
USER_EXCEPTION,
SYSTEM_EXCEPTION,
LOCATION_FORWARD
};
// GIOP 1.0
struct ReplyHeader_1_0 { // Renamed from ReplyHeader
IOP::ServiceContextList service_context;
unsigned long request_id;
ReplyStatusType_1_0 reply_status;
};
// GIOP 1.1
// Same Header contents for 1.0 and 1.1
typedef ReplyHeader_1_0 ReplyHeader_1_1;
#else
// GIOP 1.2
enum ReplyStatusType_1_2 {
NO_EXCEPTION,
USER_EXCEPTION,
SYSTEM_EXCEPTION,
LOCATION_FORWARD,
LOCATION_FORWARD_PERM,// new value for 1.2
NEEDS_ADDRESSING_MODE // new value for 1.2
};
struct ReplyHeader_1_2 {
unsigned long request_id;
ReplyStatusType_1_2 reply_status;
IOP::ServiceContextList service_context;
};
#endif // GIOP_1_2
struct SystemExceptionReplyBody {
string exception_id;
unsigned long minor_code_value;
unsigned long completion_status;
};
struct CancelRequestHeader {
unsigned long request_id;
};
// GIOP 1.0
struct LocateRequestHeader_1_0 { // Renamed LocationRequestHeader
unsigned long request_id;
sequence <octet> object_key;
};
// GIOP 1.1
// Same Header contents for 1.0 and 1.1
typedef LocateRequestHeader_1_0 LocateRequestHeader_1_1;
// GIOP 1.2
struct LocateRequestHeader_1_2 {
unsigned long request_id;
TargetAddress target;
};
#ifndef GIOP_1_2 // We're supporting all versions
// GIOP 1.0 and 1.1
enum LocateStatusType_1_0 { // Renamed from LocateStatusType
UNKNOWN_OBJECT,
OBJECT_HERE,
OBJECT_FORWARD
};
// GIOP 1.0
struct LocateReplyHeader_1_0 { // Renamed from LocateReplyHeader
unsigned long request_id;
LocateStatusType_1_0 locate_status;
};
// GIOP 1.1
// same Header contents for 1.0 and 1.1
typedef LocateReplyHeader_1_0 LocateReplyHeader_1_1;
#else
// GIOP 1.2
enum LocateStatusType_1_2 {
UNKNOWN_OBJECT,
OBJECT_HERE,
OBJECT_FORWARD,
OBJECT_FORWARD_PERM, // new value for GIOP 1.2
LOC_SYSTEM_EXCEPTION, // new value for GIOP 1.2
LOC_NEEDS_ADDRESSING_MODE // new value for GIOP 1.2
};
struct LocateReplyHeader_1_2 {
unsigned long request_id;
LocateStatusType_1_2 locate_status;
};
#endif // GIOP_1_2
// GIOP 1.2
struct FragmentHeader_1_2 {
unsigned long request_id;
};
};

View file

@ -1,48 +0,0 @@
/*
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @(#)GIOP.idl 1.0 00/05/21
*
*/
#include "IOP.idl"
module messages {
typedef short AddressingDisposition;
const short KeyAddr = 0;
const short ProfileAddr = 1;
const short ReferenceAddr = 2;
struct IORAddressingInfo {
unsigned long selected_profile_index;
IOP::IOR ior;
};
union TargetAddress switch (AddressingDisposition) {
case KeyAddr: sequence <octet> object_key;
case ProfileAddr: IOP::TaggedProfile profile;
case ReferenceAddr: IORAddressingInfo ior;
};
};

View file

@ -1,408 +0,0 @@
/*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "Interceptors.idl"
module PortableActivationIDL {
/** Possible values for endpointType argument on Server.getEndpoint()
* If you change the value of this constant then update
* core.EndPoint accordingly. It has a duplicate definition
* to avoid a compilation dependency.
*/
const string IIOP_CLEAR_TEXT = "IIOP_CLEAR_TEXT";
/** Raised if getEndpoint is called on a server callback object for
* an invalid endpoint type
*/
exception NoSuchEndPoint {} ;
/** Raised if an attempt is made to retrieve ports corresponding to
* non-registered ORB
*/
exception InvalidORBid {} ;
/** Raised if an operation is attempted against an invalid server ID.
*/
exception ServerNotRegistered {
PortableInterceptor::ServerId serverId ;
};
/** Raised if an operation is attempted for a server that is not running,
* and the server is required to be running for the operation.
*/
exception ServerNotActive {
PortableInterceptor::ServerId serverId ;
};
/** Raised if an operation is attempted against a server that is in a
* hold down state. A server becomes held down if it fails to activate
* within 10 seconds.
*/
exception ServerHeldDown {
PortableInterceptor::ServerId serverId ;
};
/** Raised if an attempt is made to activate a server that is already
* running.
*/
exception ServerAlreadyActive{
PortableInterceptor::ServerId serverId ;
};
/** Raised if an attempt is made to register a serverdef with the
* same applicationName as an existing serverdef.
*/
exception ServerAlreadyRegistered {
PortableInterceptor::ServerId serverId;
};
/** Raised if an attempt is made to install a server that is currently
* installed. Note that a newly created server starts out in an uninstalled
* state.
*/
exception ServerAlreadyInstalled {
PortableInterceptor::ServerId serverId;
} ;
/** Raised if an attempt is made to uninstall a server that is currently
* uninstalled. Note that a newly created server starts out in an
* uninstalled
* state.
*/
exception ServerAlreadyUninstalled {
PortableInterceptor::ServerId serverId;
} ;
/** Raised if an attempt is made to register an invalid serverdef.
*/
exception BadServerDefinition {
string reason;
};
/** Raised if an attempt is made to register endpoints for the
* same ORB again
*/
exception ORBAlreadyRegistered {
PortableInterceptor::ORBId orbId;
};
/** Type of TCP port number, used in structures that describe
* transport endpoints. The valid range is actually 0-65535, but
* we use a long here to avoid signed/unsigned conversion headaches
* in Java.
*/
typedef long TCPPort ;
/** Sequence of server Ids, used for queries about servers.
*/
typedef sequence<PortableInterceptor::ServerId> ServerIds;
/** End point information for one particular kind of port associated with an
* an ORB. This is only used in the
* Activator interface, which must always run on the same host as the daemon,
* therefore we do not need the host name here.
*/
struct EndPointInfo {
string endpointType;
TCPPort port;
};
/** A list of endpoint information for a particular ORB.
*/
typedef sequence<EndPointInfo> EndpointInfoList;
/** struct contain ORB and port info for a particular type of endpoint.
* This is only used in the
* Activator interface, which must always run on the same host as the daemon,
* therefore we do not need the host name here.
*/
struct ORBPortInfo {
PortableInterceptor::ORBId orbId;
TCPPort port;
};
/** A list of ORB and port information for a particular endpoint type.
*/
typedef sequence<ORBPortInfo> ORBPortInfoList;
/** A list of ORB IDs.
*/
typedef sequence<PortableInterceptor::ORBId> ORBidList;
/** Server callback interface, passed to Activator in registerServer method.
*/
interface ServerProxy {
/** Shutdown this server. Returns after orb.shutdown() completes.
*/
void shutdown();
/** Install the server. Returns after the install hook completes
* execution in the server.
*/
void install();
/** Uninstall the server. Returns after the uninstall hook
* completes execution.
*/
void uninstall();
};
/** ORB callback interface, passed to Activator in registerORB method.
*/
interface ORBProxy {
/** Method used to cause ORB to activate the named adapter, if possible.
* This will cause the named POA to register itself with the activator as
* a side effect. This should always happen before this call can complete.
* This method returns true if adapter activation succeeded, otherwise it
* returns false.
*/
boolean activate_adapter( in PortableInterceptor::AdapterName name ) ;
} ;
interface Activator {
/*******************************************************
* Server State Change Methods
********************************************************/
/** A new ORB started server registers itself with the Activator
*/
void registerServer(in PortableInterceptor::ServerId serverId, in ServerProxy serverObj)
raises (ServerNotRegistered);
/** A server is shutting down that was started by this activator.
* Complete termination of the server is detected by the death of the
* process implementing the server.
*/
void serverGoingDown( in PortableInterceptor::ServerId serverId ) ;
/** Called whenever an ORB instance is created. This registers
* the transport endpoints and the ORB proxy callback object.
* Note that we cannot detect when an ORB shuts down, although
* all of the POA shutdowns should still be reported.
*/
void registerORB( in PortableInterceptor::ServerId serverId, in PortableInterceptor::ORBId orbId,
in ORBProxy orb, in EndpointInfoList endPointInfo)
raises (ServerNotRegistered,NoSuchEndPoint, ORBAlreadyRegistered) ;
/** Construct or find an ORBD object template corresponding to the
* server's object template and return it. Called whenever a
* persistent POA is created.
*/
PortableInterceptor::ObjectReferenceTemplate registerPOA(
in PortableInterceptor::ServerId serverId, in PortableInterceptor::ORBId orbId,
in PortableInterceptor::ObjectReferenceTemplate poaTemplate ) ;
/** Called whenever a POA is destroyed.
*/
void poaDestroyed(
in PortableInterceptor::ServerId serverId, in PortableInterceptor::ORBId orbId,
in PortableInterceptor::ObjectReferenceTemplate poaTemplate ) ;
/*******************************************************
* Server Control Methods
********************************************************/
/** If the server is not running, start it up. This is allowed
* whether or not the server has been installed.
*/
void activate(in PortableInterceptor::ServerId serverId)
raises (ServerAlreadyActive, ServerNotRegistered, ServerHeldDown);
/** If the server is running, shut it down
*/
void shutdown(in PortableInterceptor::ServerId serverId)
raises (ServerNotActive, ServerNotRegistered);
/** Invoke the server install hook. If the server is not
* currently running, this method will activate it.
*/
void install(in PortableInterceptor::ServerId serverId)
raises (ServerNotRegistered, ServerHeldDown,
ServerAlreadyInstalled);
/** Invoke the server uninstall hook. If the server is not
* currently running, this method will activate it.
* After this hook completes, the server may still be running.
*/
void uninstall(in PortableInterceptor::ServerId serverId)
raises (ServerNotRegistered, ServerHeldDown,
ServerAlreadyUninstalled);
/*******************************************************
* Accessors
********************************************************/
/** list active servers
*/
ServerIds getActiveServers();
/** list all registered ORBs for a server
*/
ORBidList getORBNames(in PortableInterceptor::ServerId serverId)
raises (ServerNotRegistered);
/** Find the server template that corresponds to the ORBD's
* adapter id.
*/
PortableInterceptor::ObjectReferenceTemplate lookupPOATemplate(
in PortableInterceptor::ServerId serverId, in PortableInterceptor::ORBId orbId,
in PortableInterceptor::AdapterName orbAdapterName ) ;
};
interface Locator {
/** struct to return the list of endpoints for a server for a specific
* endpoint type.
*/
struct ServerLocationPerType {
string hostname;
ORBPortInfoList ports;
};
/** struct to return the list of endpoints for a server for a specific
* ORB
*/
struct ServerLocationPerORB {
string hostname;
EndpointInfoList ports;
};
/** locate server - returns the port with a specific type for all registered
* ORBs of an active server.
* Starts the server if it is not already running.
*/
ServerLocationPerType locateServer(
in PortableInterceptor::ServerId serverId,
in string endPoint)
raises(NoSuchEndPoint, ServerNotRegistered, ServerHeldDown);
/** locate server - returns all ports registered with a specified ORB for
* an active server
* Starts the server if it is not already running.
*/
ServerLocationPerORB locateServerForORB(
in PortableInterceptor::ServerId serverId,
in PortableInterceptor::ORBId orbId)
raises(InvalidORBid, ServerNotRegistered, ServerHeldDown);
/** get the port for the endpoint of the locator
*/
TCPPort getEndpoint(in string endPointType)
raises(NoSuchEndPoint);
/** Useful from external BadServerIdHandlers which need
* to pick a particular port type.
*/
TCPPort getServerPortForType(
in ServerLocationPerORB location,
in string endPointType)
raises(NoSuchEndPoint);
};
/** Interface used to combine the Activator and Locator when both are
* implemented together in the same process, as is currently the case
* for our implementation.
*/
interface ServerManager : Activator, Locator { };
/** Interface used to support binding references in the bootstrap name
* service.
*/
interface InitialNameService {
exception NameAlreadyBound {};
/** bind initial name
*/
void bind (
in string name,
in Object obj,
in boolean isPersistant) raises (NameAlreadyBound);
};
interface Repository {
/** server program definition.
*/
struct ServerDef {
string applicationName; // alias used for servers with identical
// serverName values.
string serverName; // Class name of server's main class.
string serverClassPath; // class path used to run the server.
string serverArgs; // arguments passed to the server
string serverVmArgs; // arguments passed to the server's Java VM1
boolean isInstalled; // Whether or not the server has been installed
};
/** register server definition.
* This returns the serverId of the server. A newly created server is
* always uninstalled.
*/
PortableInterceptor::ServerId registerServer (in ServerDef serverDef)
raises (ServerAlreadyRegistered, BadServerDefinition);
/** unregister server definition
*/
void unregisterServer (in PortableInterceptor::ServerId serverId)
raises (ServerNotRegistered);
/** get server definition
*/
ServerDef getServer(in PortableInterceptor::ServerId serverId)
raises (ServerNotRegistered);
/** Return whether the server has been installed
*/
boolean isInstalled( in PortableInterceptor::ServerId serverId )
raises (ServerNotRegistered);
/** Mark the server as being installed. Raises ServerAlreadyInstalled
* if the server is currently marked as installed.
*/
void install( in PortableInterceptor::ServerId serverId )
raises (ServerNotRegistered, ServerAlreadyInstalled) ;
/** Mark the server as being uninstalled. Raises ServerAlreadyUninstalled
* if the server is currently marked as uninstalled.
*/
void uninstall( in PortableInterceptor::ServerId serverId )
raises (ServerNotRegistered, ServerAlreadyUninstalled) ;
/** list registered servers
*/
ServerIds listRegisteredServers ();
/** Type used for a list of application names
*/
typedef sequence<string> AppNames ;
/** Returns list of ALL applicationNames defined in ServerDefs of registered
* servers.
*/
AppNames getApplicationNames();
/** Find the ServerID associated with the given application name.
*/
PortableInterceptor::ServerId getServerID( in string applicationName )
raises (ServerNotRegistered) ;
};
};

View file

@ -1,49 +0,0 @@
/*
* Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.activation;
import org.omg.CORBA.ORB;
import java.io.PrintStream;
/**
* @author Rohit Garg
* @since JDK1.2
*/
public interface CommandHandler
{
String getCommandName();
public final static boolean shortHelp = true;
public final static boolean longHelp = false;
void printCommandHelp(PrintStream out, boolean helpType);
public final static boolean parseError = true;
public final static boolean commandDone = false;
boolean processCommand(String[] cmd, ORB orb, PrintStream out);
}

View file

@ -1,63 +0,0 @@
/*
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.activation;
import java.io.File;
import org.omg.CosNaming.NamingContext;
import com.sun.corba.se.spi.orb.ORB;
import com.sun.corba.se.impl.naming.pcosnaming.NameService;
import com.sun.corba.se.impl.orbutil.ORBConstants;
// REVISIT: After Merlin to see if we can get rid of this Thread and
// make the registration of PNameService for INS and BootStrap neat.
public class NameServiceStartThread extends java.lang.Thread
{
private ORB orb;
private File dbDir;
public NameServiceStartThread( ORB theOrb, File theDir )
{
orb = theOrb;
dbDir = theDir;
}
public void run( )
{
try {
// start Name Service
NameService nameService = new NameService(orb, dbDir );
NamingContext rootContext = nameService.initialNamingContext();
orb.register_initial_reference(
ORBConstants.PERSISTENT_NAME_SERVICE_NAME, rootContext );
} catch( Exception e ) {
System.err.println(
"NameService did not start successfully" );
e.printStackTrace( );
}
}
}

View file

@ -1,352 +0,0 @@
/*
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.activation;
import java.io.File;
import java.util.Properties;
import org.omg.CORBA.INITIALIZE;
import org.omg.CORBA.INTERNAL;
import org.omg.CORBA.CompletionStatus;
import org.omg.CosNaming.NamingContext;
import org.omg.PortableServer.POA;
import com.sun.corba.se.pept.transport.Acceptor;
import com.sun.corba.se.spi.activation.Repository;
import com.sun.corba.se.spi.activation.RepositoryPackage.ServerDef;
import com.sun.corba.se.spi.activation.Locator;
import com.sun.corba.se.spi.activation.LocatorHelper;
import com.sun.corba.se.spi.activation.Activator;
import com.sun.corba.se.spi.activation.ActivatorHelper;
import com.sun.corba.se.spi.activation.ServerAlreadyRegistered;
import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo;
import com.sun.corba.se.spi.transport.SocketInfo;
import com.sun.corba.se.spi.orb.ORB;
import com.sun.corba.se.impl.legacy.connection.SocketFactoryAcceptorImpl;
import com.sun.corba.se.impl.naming.cosnaming.TransientNameService;
import com.sun.corba.se.impl.naming.pcosnaming.NameService;
import com.sun.corba.se.impl.orbutil.ORBConstants;
import com.sun.corba.se.impl.orbutil.CorbaResourceUtil;
import com.sun.corba.se.impl.transport.SocketOrChannelAcceptorImpl;
/**
*
* @author Rohit Garg
* @since JDK1.2
*/
public class ORBD
{
private int initSvcPort;
protected void initializeBootNaming(ORB orb)
{
// create a bootstrap server
initSvcPort = orb.getORBData().getORBInitialPort();
Acceptor acceptor;
// REVISIT: see ORBConfigurator. use factory in TransportDefault.
if (orb.getORBData().getLegacySocketFactory() == null) {
acceptor =
new SocketOrChannelAcceptorImpl(
orb,
initSvcPort,
LegacyServerSocketEndPointInfo.BOOT_NAMING,
SocketInfo.IIOP_CLEAR_TEXT);
} else {
acceptor =
new SocketFactoryAcceptorImpl(
orb,
initSvcPort,
LegacyServerSocketEndPointInfo.BOOT_NAMING,
SocketInfo.IIOP_CLEAR_TEXT);
}
orb.getCorbaTransportManager().registerAcceptor(acceptor);
}
protected ORB createORB(String[] args)
{
Properties props = System.getProperties();
// For debugging.
//props.put( ORBConstants.DEBUG_PROPERTY, "naming" ) ;
//props.put( ORBConstants.DEBUG_PROPERTY, "transport,giop,naming" ) ;
props.put( ORBConstants.SERVER_ID_PROPERTY, "1000" ) ;
props.put( ORBConstants.PERSISTENT_SERVER_PORT_PROPERTY,
props.getProperty( ORBConstants.ORBD_PORT_PROPERTY,
Integer.toString(
ORBConstants.DEFAULT_ACTIVATION_PORT ) ) ) ;
// See Bug 4396928 for more information about why we are initializing
// the ORBClass to PIORB (now ORBImpl, but should check the bugid).
props.put("org.omg.CORBA.ORBClass",
"com.sun.corba.se.impl.orb.ORBImpl");
return (ORB) ORB.init(args, props);
}
private void run(String[] args)
{
try {
// parse the args and try setting the values for these
// properties
processArgs(args);
ORB orb = createORB(args);
if (orb.orbdDebugFlag)
System.out.println( "ORBD begins initialization." ) ;
boolean firstRun = createSystemDirs( ORBConstants.DEFAULT_DB_DIR );
startActivationObjects(orb);
if (firstRun) // orbd is being run the first time
installOrbServers(getRepository(), getActivator());
if (orb.orbdDebugFlag) {
System.out.println( "ORBD is ready." ) ;
System.out.println("ORBD serverid: " +
System.getProperty(ORBConstants.SERVER_ID_PROPERTY));
System.out.println("activation dbdir: " +
System.getProperty(ORBConstants.DB_DIR_PROPERTY));
System.out.println("activation port: " +
System.getProperty(ORBConstants.ORBD_PORT_PROPERTY));
String pollingTime = System.getProperty(
ORBConstants.SERVER_POLLING_TIME);
if( pollingTime == null ) {
pollingTime = Integer.toString(
ORBConstants.DEFAULT_SERVER_POLLING_TIME );
}
System.out.println("activation Server Polling Time: " +
pollingTime + " milli-seconds ");
String startupDelay = System.getProperty(
ORBConstants.SERVER_STARTUP_DELAY);
if( startupDelay == null ) {
startupDelay = Integer.toString(
ORBConstants.DEFAULT_SERVER_STARTUP_DELAY );
}
System.out.println("activation Server Startup Delay: " +
startupDelay + " milli-seconds " );
}
// The following two lines start the Persistent NameService
NameServiceStartThread theThread =
new NameServiceStartThread( orb, dbDir );
theThread.start( );
orb.run();
} catch( org.omg.CORBA.COMM_FAILURE cex ) {
System.out.println( CorbaResourceUtil.getText("orbd.commfailure"));
System.out.println( cex );
cex.printStackTrace();
} catch( org.omg.CORBA.INTERNAL iex ) {
System.out.println( CorbaResourceUtil.getText(
"orbd.internalexception"));
System.out.println( iex );
iex.printStackTrace();
} catch (Exception ex) {
System.out.println(CorbaResourceUtil.getText(
"orbd.usage", "orbd"));
System.out.println( ex );
ex.printStackTrace();
}
}
private void processArgs(String[] args)
{
Properties props = System.getProperties();
for (int i=0; i < args.length; i++) {
if (args[i].equals("-port")) {
if ((i+1) < args.length) {
props.put(ORBConstants.ORBD_PORT_PROPERTY, args[++i]);
} else {
System.out.println(CorbaResourceUtil.getText(
"orbd.usage", "orbd"));
}
} else if (args[i].equals("-defaultdb")) {
if ((i+1) < args.length) {
props.put(ORBConstants.DB_DIR_PROPERTY, args[++i]);
} else {
System.out.println(CorbaResourceUtil.getText(
"orbd.usage", "orbd"));
}
} else if (args[i].equals("-serverid")) {
if ((i+1) < args.length) {
props.put(ORBConstants.SERVER_ID_PROPERTY, args[++i]);
} else {
System.out.println(CorbaResourceUtil.getText(
"orbd.usage", "orbd"));
}
} else if (args[i].equals("-serverPollingTime")) {
if ((i+1) < args.length) {
props.put(ORBConstants.SERVER_POLLING_TIME, args[++i]);
} else {
System.out.println(CorbaResourceUtil.getText(
"orbd.usage", "orbd"));
}
} else if (args[i].equals("-serverStartupDelay")) {
if ((i+1) < args.length) {
props.put(ORBConstants.SERVER_STARTUP_DELAY, args[++i]);
} else {
System.out.println(CorbaResourceUtil.getText(
"orbd.usage", "orbd"));
}
}
}
}
/**
* Ensure that the Db directory exists. If not, create the Db
* and the log directory and return true. Otherwise return false.
*/
protected boolean createSystemDirs(String defaultDbDir)
{
boolean dirCreated = false;
Properties props = System.getProperties();
String fileSep = props.getProperty("file.separator");
// determine the ORB db directory
dbDir = new File (props.getProperty( ORBConstants.DB_DIR_PROPERTY,
props.getProperty("user.dir") + fileSep + defaultDbDir));
// create the db and the logs directories
dbDirName = dbDir.getAbsolutePath();
props.put(ORBConstants.DB_DIR_PROPERTY, dbDirName);
if (!dbDir.exists()) {
dbDir.mkdir();
dirCreated = true;
}
File logDir = new File (dbDir, ORBConstants.SERVER_LOG_DIR ) ;
if (!logDir.exists()) logDir.mkdir();
return dirCreated;
}
protected File dbDir;
protected File getDbDir()
{
return dbDir;
}
private String dbDirName;
protected String getDbDirName()
{
return dbDirName;
}
protected void startActivationObjects(ORB orb) throws Exception
{
// create Initial Name Service object
initializeBootNaming(orb);
// create Repository object
repository = new RepositoryImpl(orb, dbDir, orb.orbdDebugFlag );
orb.register_initial_reference( ORBConstants.SERVER_REPOSITORY_NAME, repository );
// create Locator and Activator objects
ServerManagerImpl serverMgr =
new ServerManagerImpl( orb,
orb.getCorbaTransportManager(),
repository,
getDbDirName(),
orb.orbdDebugFlag );
locator = LocatorHelper.narrow(serverMgr);
orb.register_initial_reference( ORBConstants.SERVER_LOCATOR_NAME, locator );
activator = ActivatorHelper.narrow(serverMgr);
orb.register_initial_reference( ORBConstants.SERVER_ACTIVATOR_NAME, activator );
// start Name Service
TransientNameService nameService = new TransientNameService(orb,
ORBConstants.TRANSIENT_NAME_SERVICE_NAME);
}
protected Locator locator;
protected Locator getLocator()
{
return locator;
}
protected Activator activator;
protected Activator getActivator()
{
return activator;
}
protected RepositoryImpl repository;
protected RepositoryImpl getRepository()
{
return repository;
}
/**
* Go through the list of ORB Servers and initialize and start
* them up.
*/
protected void installOrbServers(RepositoryImpl repository,
Activator activator)
{
int serverId;
String[] server;
ServerDef serverDef;
for (int i=0; i < orbServers.length; i++) {
try {
server = orbServers[i];
serverDef = new ServerDef(server[1], server[2],
server[3], server[4], server[5] );
serverId = Integer.valueOf(orbServers[i][0]).intValue();
repository.registerServer(serverDef, serverId);
activator.activate(serverId);
} catch (Exception ex) {}
}
}
public static void main(String[] args) {
ORBD orbd = new ORBD();
orbd.run(args);
}
/**
* List of servers to be auto registered and started by the ORBd.
*
* Each server entry is of the form {id, name, path, args, vmargs}.
*/
private static String[][] orbServers = {
{""}
};
}

View file

@ -1,105 +0,0 @@
/*
* Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.activation;
import java.util.*;
import com.sun.corba.se.impl.orbutil.ORBConstants;
/** ProcessMonitorThread is started when ServerManager is instantiated. The
* thread wakes up every minute (This can be changed by setting sleepTime) and
* makes sure that all the processes (Servers) registered with the ServerTool
* are healthy. If not the state in ServerTableEntry will be changed to
* De-Activated.
* Note: This thread can be killed from the main thread by calling
* interrupThread()
*/
public class ProcessMonitorThread extends java.lang.Thread {
private HashMap serverTable;
private int sleepTime;
private static ProcessMonitorThread instance = null;
private ProcessMonitorThread( HashMap ServerTable, int SleepTime ) {
serverTable = ServerTable;
sleepTime = SleepTime;
}
public void run( ) {
while( true ) {
try {
// Sleep's for a specified time, before checking
// the Servers health. This will repeat as long as
// the ServerManager (ORBD) is up and running.
Thread.sleep( sleepTime );
} catch( java.lang.InterruptedException e ) {
break;
}
Iterator serverList;
synchronized ( serverTable ) {
// Check each ServerTableEntry to make sure that they
// are in the right state.
serverList = serverTable.values().iterator();
}
try {
checkServerHealth( serverList );
} catch( ConcurrentModificationException e ) {
break;
}
}
}
private void checkServerHealth( Iterator serverList ) {
if( serverList == null ) return;
while (serverList.hasNext( ) ) {
ServerTableEntry entry = (ServerTableEntry) serverList.next();
entry.checkProcessHealth( );
}
}
static void start( HashMap serverTable ) {
int sleepTime = ORBConstants.DEFAULT_SERVER_POLLING_TIME;
String pollingTime = System.getProperties().getProperty(
ORBConstants.SERVER_POLLING_TIME );
if ( pollingTime != null ) {
try {
sleepTime = Integer.parseInt( pollingTime );
} catch (Exception e ) {
// Too late to complain, Just use the default
// sleepTime
}
}
instance = new ProcessMonitorThread( serverTable,
sleepTime );
instance.setDaemon( true );
instance.start();
}
static void interruptThread( ) {
instance.interrupt();
}
}

View file

@ -1,474 +0,0 @@
/*
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.activation;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Properties;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Vector;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.INITIALIZE;
import org.omg.CORBA.INTERNAL;
import org.omg.CORBA.SystemException;
import com.sun.corba.se.spi.activation.BadServerDefinition;
import com.sun.corba.se.spi.activation.RepositoryPackage.ServerDef;
import com.sun.corba.se.spi.activation._RepositoryImplBase;
import com.sun.corba.se.spi.activation.ServerAlreadyRegistered;
import com.sun.corba.se.spi.activation.ServerAlreadyInstalled;
import com.sun.corba.se.spi.activation.ServerAlreadyUninstalled;
import com.sun.corba.se.spi.activation.ServerNotRegistered;
import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo;
import com.sun.corba.se.spi.transport.SocketOrChannelAcceptor;
import com.sun.corba.se.spi.orb.ORB;
import com.sun.corba.se.impl.orbutil.ORBConstants;
import com.sun.corba.se.spi.logging.CORBALogDomains;
import com.sun.corba.se.impl.logging.ActivationSystemException;
/**
*
* @author Rohit Garg
* @since JDK1.2
*/
public class RepositoryImpl extends _RepositoryImplBase
implements Serializable
{
// added serialver computed by the tool
private static final long serialVersionUID = 8458417785209341858L;
RepositoryImpl(ORB orb, File dbDir, boolean debug)
{
this.debug = debug ;
this.orb = orb;
wrapper = ActivationSystemException.get( orb, CORBALogDomains.ORBD_REPOSITORY ) ;
// if databse does not exist, create it otherwise read it in
File dbFile = new File(dbDir, "servers.db");
if (!dbFile.exists()) {
db = new RepositoryDB(dbFile);
db.flush();
} else {
try {
FileInputStream fis = new FileInputStream(dbFile);
ObjectInputStream ois = new ObjectInputStream(fis);
db = (RepositoryDB) ois.readObject();
ois.close();
} catch (Exception e) {
throw wrapper.cannotReadRepositoryDb( e ) ;
}
}
// export the repository
orb.connect(this);
}
private String printServerDef( ServerDef sd )
{
return "ServerDef[applicationName=" + sd.applicationName +
" serverName=" + sd.serverName +
" serverClassPath=" + sd.serverClassPath +
" serverArgs=" + sd. serverArgs +
" serverVmArgs=" + sd.serverVmArgs +
"]" ;
}
public int registerServer(ServerDef serverDef, int theServerId)
throws ServerAlreadyRegistered
{
int serverId;
DBServerDef server = null;
synchronized (db) {
// check if server already registered
Enumeration enumeration = db.serverTable.elements();
while (enumeration.hasMoreElements()) {
server = (DBServerDef) enumeration.nextElement();
if (serverDef.applicationName.equals(server.applicationName)) {
if (debug)
System.out.println(
"RepositoryImpl: registerServer called " +
"to register ServerDef " +
printServerDef( serverDef ) +
" with " + ((theServerId==illegalServerId) ?
"a new server Id" : ("server Id " + theServerId)) +
" FAILED because it is already registered." ) ;
throw (new ServerAlreadyRegistered(server.id));
}
}
// generate a new server id
if (theServerId == illegalServerId)
serverId = db.incrementServerIdCounter();
else
serverId = theServerId;
// add server def to the database
server = new DBServerDef(serverDef, serverId);
db.serverTable.put(new Integer(serverId), server);
db.flush();
if (debug)
if (theServerId==illegalServerId)
System.out.println( "RepositoryImpl: registerServer called " +
"to register ServerDef " + printServerDef( serverDef ) +
" with new serverId " + serverId ) ;
else
System.out.println( "RepositoryImpl: registerServer called " +
"to register ServerDef " + printServerDef( serverDef ) +
" with assigned serverId " + serverId ) ;
return serverId;
}
}
public int registerServer(ServerDef serverDef)
throws ServerAlreadyRegistered, BadServerDefinition
{
// verify that the entry is valid
LegacyServerSocketEndPointInfo endpoint =
orb.getLegacyServerSocketManager()
.legacyGetEndpoint(LegacyServerSocketEndPointInfo.BOOT_NAMING);
int initSvcPort = ((SocketOrChannelAcceptor)endpoint)
.getServerSocket().getLocalPort();
ServerTableEntry entry = new ServerTableEntry( wrapper,
illegalServerId, serverDef, (int) initSvcPort, "", true, debug );
switch (entry.verify()) {
case ServerMain.OK:
break;
case ServerMain.MAIN_CLASS_NOT_FOUND:
throw new BadServerDefinition("main class not found.");
case ServerMain.NO_MAIN_METHOD:
throw new BadServerDefinition("no main method found.");
case ServerMain.APPLICATION_ERROR:
throw new BadServerDefinition("server application error.");
default:
throw new BadServerDefinition("unknown Exception.");
}
return registerServer(serverDef, illegalServerId);
}
public void unregisterServer(int serverId) throws ServerNotRegistered {
DBServerDef server = null;
Integer id = new Integer(serverId);
synchronized (db) {
// check to see if the server is registered
server = (DBServerDef) db.serverTable.get(id);
if (server == null) {
if (debug)
System.out.println(
"RepositoryImpl: unregisterServer for serverId " +
serverId + " called: server not registered" ) ;
throw (new ServerNotRegistered());
}
// remove server from the database
db.serverTable.remove(id);
db.flush();
}
if (debug)
System.out.println(
"RepositoryImpl: unregisterServer for serverId " + serverId +
" called" ) ;
}
private DBServerDef getDBServerDef(int serverId) throws ServerNotRegistered
{
Integer id = new Integer(serverId);
DBServerDef server = (DBServerDef) db.serverTable.get(id);
if (server == null)
throw new ServerNotRegistered( serverId );
return server ;
}
public ServerDef getServer(int serverId) throws ServerNotRegistered
{
DBServerDef server = getDBServerDef( serverId ) ;
ServerDef serverDef = new ServerDef(server.applicationName, server.name,
server.classPath, server.args, server.vmArgs);
if (debug)
System.out.println(
"RepositoryImpl: getServer for serverId " + serverId +
" returns " + printServerDef( serverDef ) ) ;
return serverDef;
}
public boolean isInstalled(int serverId) throws ServerNotRegistered {
DBServerDef server = getDBServerDef( serverId ) ;
return server.isInstalled ;
}
public void install( int serverId )
throws ServerNotRegistered, ServerAlreadyInstalled
{
DBServerDef server = getDBServerDef( serverId ) ;
if (server.isInstalled)
throw new ServerAlreadyInstalled( serverId ) ;
else {
server.isInstalled = true ;
db.flush() ;
}
}
public void uninstall( int serverId )
throws ServerNotRegistered, ServerAlreadyUninstalled
{
DBServerDef server = getDBServerDef( serverId ) ;
if (!server.isInstalled)
throw new ServerAlreadyUninstalled( serverId ) ;
else {
server.isInstalled = false ;
db.flush() ;
}
}
public int[] listRegisteredServers() {
synchronized (db) {
int i=0;
int servers[] = new int[db.serverTable.size()];
Enumeration enumeration = db.serverTable.elements();
while (enumeration.hasMoreElements()) {
DBServerDef server = (DBServerDef) enumeration.nextElement();
servers[i++] = server.id;
}
if (debug) {
StringBuffer sb = new StringBuffer() ;
for (int ctr=0; ctr<servers.length; ctr++) {
sb.append( ' ' ) ;
sb.append( servers[ctr] ) ;
}
System.out.println(
"RepositoryImpl: listRegisteredServers returns" +
sb.toString() ) ;
}
return servers;
}
}
public int getServerID(String applicationName) throws ServerNotRegistered {
synchronized (db) {
int result = -1 ;
for (Enumeration serverIds = db.serverTable.keys();
serverIds.hasMoreElements();)
{
Integer nextServerId = (Integer) serverIds.nextElement();
DBServerDef dbServerDef =
(DBServerDef) db.serverTable.get(nextServerId);
if (dbServerDef.applicationName.equals(applicationName)) {
result = nextServerId.intValue();
break ;
}
}
if (debug)
System.out.println("RepositoryImpl: getServerID for " +
applicationName + " is " + result ) ;
if (result == -1) {
throw (new ServerNotRegistered());
} else {
return result ;
}
}
}
public String[] getApplicationNames() {
synchronized (db) {
Vector v = new Vector();
for (Enumeration serverIds = db.serverTable.keys();
serverIds.hasMoreElements();)
{
Integer nextServerId = (Integer) serverIds.nextElement();
DBServerDef dbServerDef = (DBServerDef)db.serverTable.get(
nextServerId);
if (!dbServerDef.applicationName.equals(""))
v.addElement( dbServerDef.applicationName ) ;
}
String[] apps = new String[v.size()];
for (int i = 0; i < v.size(); i++) {
apps[i] = (String)v.elementAt(i);
}
if (debug) {
StringBuffer sb = new StringBuffer() ;
for (int ctr=0; ctr<apps.length; ctr++) {
sb.append( ' ' ) ;
sb.append( apps[ctr] ) ;
}
System.out.println( "RepositoryImpl: getApplicationNames returns " +
sb.toString() ) ;
}
return apps;
}
}
/**
* Typically the Repositoy is created within the ORBd VM but it can
* be independently started as well.
*/
public static void main(String args[]) {
boolean debug = false ;
for (int ctr=0; ctr<args.length; ctr++)
if (args[ctr].equals("-debug"))
debug = true ;
try {
// See Bug 4396928 for more information about why we are
// initializing the ORBClass to PIORB (now ORBImpl, but see the bug).
Properties props = new Properties();
props.put("org.omg.CORBA.ORBClass",
"com.sun.corba.se.impl.orb.ORBImpl");
ORB orb = (ORB) ORB.init(args, props);
// create the repository object
String db = System.getProperty( ORBConstants.DB_PROPERTY,
ORBConstants.DEFAULT_DB_NAME );
RepositoryImpl repository = new RepositoryImpl(orb, new File(db),
debug);
// wait for shutdown
orb.run();
} catch (Exception ex) {
ex.printStackTrace();
}
}
transient private boolean debug = false;
final static int illegalServerId = -1;
transient private RepositoryDB db = null;
transient ORB orb = null;
transient ActivationSystemException wrapper ;
class RepositoryDB implements Serializable
{
File db;
Hashtable serverTable;
Integer serverIdCounter;
RepositoryDB(File dbFile) {
db = dbFile;
// initialize the Server Id counter and hashtable.
// the lower id range is reserved for system servers
serverTable = new Hashtable(255);
serverIdCounter = new Integer(256);
}
int incrementServerIdCounter()
{
int value = serverIdCounter.intValue();
serverIdCounter = new Integer(++value);
return value;
}
void flush()
{
try {
db.delete();
FileOutputStream fos = new FileOutputStream(db);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(this);
oos.flush();
oos.close();
} catch (Exception ex) {
throw wrapper.cannotWriteRepositoryDb( ex ) ;
}
}
}
class DBServerDef implements Serializable
{
public String toString() {
return "DBServerDef(applicationName=" + applicationName +
", name=" + name +
", classPath=" + classPath +
", args=" + args +
", vmArgs=" + vmArgs +
", id=" + id +
", isInstalled=" + isInstalled + ")" ;
}
DBServerDef(ServerDef server, int server_id) {
applicationName = server.applicationName ;
name = server.serverName;
classPath = server.serverClassPath;
args = server.serverArgs;
vmArgs = server.serverVmArgs;
id = server_id;
isInstalled = false ;
}
String applicationName;
String name;
String classPath;
String args;
String vmArgs;
boolean isInstalled ;
int id;
}
}

View file

@ -1,383 +0,0 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.activation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.io.*;
import java.util.Date;
import java.util.Properties ;
import org.omg.CORBA.ORB ;
import com.sun.corba.se.spi.activation.Activator ;
import com.sun.corba.se.spi.activation.ActivatorHelper ;
import com.sun.corba.se.impl.orbutil.ORBConstants ;
/**
* @author Ken Cavanaugh
* @since JDK1.2
*/
public class ServerMain
{
/* TODO:
* 1. Rewrite all uses of ORB properties to use constants from someplace.
* The strings are scattered between here, the ORB classes, and
* ServerTableEntry.
* 2. Consider a more general log facility.
* 3. Remove ServerCallback from POAORB.
* 4. Needs to be merged with Harold's changes to support SSL.
* 5. Logs need to be internationalized.
*/
public final static int OK = 0;
public final static int MAIN_CLASS_NOT_FOUND = 1;
public final static int NO_MAIN_METHOD = 2;
public final static int APPLICATION_ERROR = 3;
public final static int UNKNOWN_ERROR = 4;
public final static int NO_SERVER_ID = 5 ;
public final static int REGISTRATION_FAILED = 6;
public static String printResult( int result )
{
switch (result) {
case OK : return "Server terminated normally" ;
case MAIN_CLASS_NOT_FOUND : return "main class not found" ;
case NO_MAIN_METHOD : return "no main method" ;
case APPLICATION_ERROR : return "application error" ;
case NO_SERVER_ID : return "server ID not defined" ;
case REGISTRATION_FAILED: return "server registration failed" ;
default : return "unknown error" ;
}
}
private void redirectIOStreams()
{
// redirect out and err streams
try {
String logDirName =
System.getProperty( ORBConstants.DB_DIR_PROPERTY ) +
System.getProperty("file.separator") +
ORBConstants.SERVER_LOG_DIR +
System.getProperty("file.separator");
File logDir = new File(logDirName);
String server = System.getProperty(
ORBConstants.SERVER_ID_PROPERTY ) ;
FileOutputStream foutStream =
new FileOutputStream(logDirName + server+".out", true);
FileOutputStream ferrStream =
new FileOutputStream(logDirName + server+".err", true);
PrintStream pSout = new PrintStream(foutStream, true);
PrintStream pSerr = new PrintStream(ferrStream, true);
System.setOut(pSout);
System.setErr(pSerr);
logInformation( "Server started" ) ;
} catch (Exception ex) {}
}
/** Write a time-stamped message to the indicated PrintStream.
*/
private static void writeLogMessage( PrintStream pstream, String msg )
{
Date date = new Date();
pstream.print( "[" + date.toString() + "] " + msg + "\n");
}
/** Write information to standard out only.
*/
public static void logInformation( String msg )
{
writeLogMessage( System.out, " " + msg ) ;
}
/** Write error message to standard out and standard err.
*/
public static void logError( String msg )
{
writeLogMessage( System.out, "ERROR: " + msg ) ;
writeLogMessage( System.err, "ERROR: " + msg ) ;
}
/** Write final message to log(s) and then terminate by calling
* System.exit( code ). If code == OK, write a normal termination
* message to standard out, otherwise write an abnormal termination
* message to standard out and standard error.
*/
public static void logTerminal( String msg, int code )
{
if (code == 0) {
writeLogMessage( System.out, " " + msg ) ;
} else {
writeLogMessage( System.out, "FATAL: " +
printResult( code ) + ": " + msg ) ;
writeLogMessage( System.err, "FATAL: " +
printResult( code ) + ": " + msg ) ;
}
System.exit( code ) ;
}
private Method getMainMethod( Class serverClass )
{
Class argTypes[] = new Class[] { String[].class } ;
Method method = null ;
try {
method = serverClass.getDeclaredMethod( "main", argTypes ) ;
} catch (Exception exc) {
logTerminal( exc.getMessage(), NO_MAIN_METHOD ) ;
}
if (!isPublicStaticVoid( method ))
logTerminal( "", NO_MAIN_METHOD ) ;
return method ;
}
private boolean isPublicStaticVoid( Method method )
{
// check modifiers: public static
int modifiers = method.getModifiers ();
if (!Modifier.isPublic (modifiers) || !Modifier.isStatic (modifiers)) {
logError( method.getName() + " is not public static" ) ;
return false ;
}
// check return type and exceptions
if (method.getExceptionTypes ().length != 0) {
logError( method.getName() + " declares exceptions" ) ;
return false ;
}
if (!method.getReturnType().equals (Void.TYPE)) {
logError( method.getName() + " does not have a void return type" ) ;
return false ;
}
return true ;
}
private Method getNamedMethod( Class serverClass, String methodName )
{
Class argTypes[] = new Class[] { org.omg.CORBA.ORB.class } ;
Method method = null ;
try {
method = serverClass.getDeclaredMethod( methodName, argTypes ) ;
} catch (Exception exc) {
return null ;
}
if (!isPublicStaticVoid( method ))
return null ;
return method ;
}
private void run(String[] args)
{
try {
redirectIOStreams() ;
String serverClassName = System.getProperty(
ORBConstants.SERVER_NAME_PROPERTY ) ;
// determine the class loader to be used for loading the class
// since ServerMain is going to be in JDK and we need to have this
// class to load application classes, this is required here.
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null)
cl = ClassLoader.getSystemClassLoader();
// determine the main class
Class serverClass = null;
try {
// determine the main class, try loading with current class loader
serverClass = Class.forName( serverClassName ) ;
} catch (ClassNotFoundException ex) {
// eat the exception and try to load using SystemClassLoader
serverClass = Class.forName( serverClassName, true, cl);
}
if (debug)
System.out.println("class " + serverClassName + " found");
// get the main method
Method mainMethod = getMainMethod( serverClass ) ;
// This piece of code is required, to verify the server definition
// without launching it.
// verify the server
boolean serverVerifyFlag = Boolean.getBoolean(
ORBConstants.SERVER_DEF_VERIFY_PROPERTY) ;
if (serverVerifyFlag) {
if (mainMethod == null)
logTerminal("", NO_MAIN_METHOD);
else {
if (debug)
System.out.println("Valid Server");
logTerminal("", OK);
}
}
registerCallback( serverClass ) ;
// build args to the main and call it
Object params [] = new Object [1];
params[0] = args;
mainMethod.invoke(null, params);
} catch (ClassNotFoundException e) {
logTerminal("ClassNotFound exception: " + e.getMessage(),
MAIN_CLASS_NOT_FOUND);
} catch (Exception e) {
logTerminal("Exception: " + e.getMessage(),
APPLICATION_ERROR);
}
}
public static void main(String[] args) {
ServerMain server = new ServerMain();
server.run(args);
}
private static final boolean debug = false;
private int getServerId()
{
Integer serverId = Integer.getInteger( ORBConstants.SERVER_ID_PROPERTY ) ;
if (serverId == null)
logTerminal( "", NO_SERVER_ID ) ;
return serverId.intValue() ;
}
private void registerCallback( Class serverClass )
{
Method installMethod = getNamedMethod( serverClass, "install" ) ;
Method uninstallMethod = getNamedMethod( serverClass, "uninstall" ) ;
Method shutdownMethod = getNamedMethod( serverClass, "shutdown" ) ;
Properties props = new Properties() ;
props.put( "org.omg.CORBA.ORBClass",
"com.sun.corba.se.impl.orb.ORBImpl" ) ;
// NOTE: Very important to pass this property, otherwise the
// Persistent Server registration will be unsucessfull.
props.put( ORBConstants.ACTIVATED_PROPERTY, "false" );
String args[] = null ;
ORB orb = ORB.init( args, props ) ;
ServerCallback serverObj = new ServerCallback( orb,
installMethod, uninstallMethod, shutdownMethod ) ;
int serverId = getServerId() ;
try {
Activator activator = ActivatorHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_ACTIVATOR_NAME ));
activator.active(serverId, serverObj);
} catch (Exception ex) {
logTerminal( "exception " + ex.getMessage(),
REGISTRATION_FAILED ) ;
}
}
}
class ServerCallback extends
com.sun.corba.se.spi.activation._ServerImplBase
{
private ORB orb;
private transient Method installMethod ;
private transient Method uninstallMethod ;
private transient Method shutdownMethod ;
private Object methodArgs[] ;
ServerCallback(ORB orb, Method installMethod, Method uninstallMethod,
Method shutdownMethod )
{
this.orb = orb;
this.installMethod = installMethod ;
this.uninstallMethod = uninstallMethod ;
this.shutdownMethod = shutdownMethod ;
orb.connect( this ) ;
methodArgs = new Object[] { orb } ;
}
private void invokeMethod( Method method )
{
if (method != null)
try {
method.invoke( null, methodArgs ) ;
} catch (Exception exc) {
ServerMain.logError( "could not invoke " + method.getName() +
" method: " + exc.getMessage() ) ;
}
}
// shutdown the ORB and wait for completion
public void shutdown()
{
ServerMain.logInformation( "Shutdown starting" ) ;
invokeMethod( shutdownMethod ) ;
orb.shutdown(true);
ServerMain.logTerminal( "Shutdown completed", ServerMain.OK ) ;
}
public void install()
{
ServerMain.logInformation( "Install starting" ) ;
invokeMethod( installMethod ) ;
ServerMain.logInformation( "Install completed" ) ;
}
public void uninstall()
{
ServerMain.logInformation( "uninstall starting" ) ;
invokeMethod( uninstallMethod ) ;
ServerMain.logInformation( "uninstall completed" ) ;
}
}

View file

@ -1,645 +0,0 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.activation;
/**
*
* @author Rohit Garg
* @author Ken Cavanaugh
* @author Hemanth Puttaswamy
* @since JDK1.2
*/
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.NoSuchElementException;
import org.omg.CORBA.OBJECT_NOT_EXIST;
import org.omg.CORBA.SystemException;
import com.sun.corba.se.spi.activation.EndPointInfo;
import com.sun.corba.se.spi.activation.IIOP_CLEAR_TEXT;
import com.sun.corba.se.spi.activation.ORBPortInfo;
import com.sun.corba.se.spi.activation.Repository;
import com.sun.corba.se.spi.activation.LocatorPackage.ServerLocation;
import com.sun.corba.se.spi.activation.LocatorPackage.ServerLocationPerORB;
import com.sun.corba.se.spi.activation.RepositoryPackage.ServerDef;
import com.sun.corba.se.spi.activation._ServerManagerImplBase;
import com.sun.corba.se.spi.activation.ServerAlreadyActive;
import com.sun.corba.se.spi.activation.ServerAlreadyInstalled;
import com.sun.corba.se.spi.activation.ServerAlreadyUninstalled;
import com.sun.corba.se.spi.activation.ServerNotRegistered;
import com.sun.corba.se.spi.activation.ORBAlreadyRegistered;
import com.sun.corba.se.spi.activation.ServerHeldDown;
import com.sun.corba.se.spi.activation.ServerNotActive;
import com.sun.corba.se.spi.activation.NoSuchEndPoint;
import com.sun.corba.se.spi.activation.InvalidORBid;
import com.sun.corba.se.spi.activation.Server;
import com.sun.corba.se.spi.activation.IIOP_CLEAR_TEXT;
import com.sun.corba.se.spi.ior.IORTemplate ;
import com.sun.corba.se.spi.ior.IOR ;
import com.sun.corba.se.spi.ior.ObjectKey ;
import com.sun.corba.se.spi.ior.ObjectKeyTemplate ;
import com.sun.corba.se.spi.ior.IORFactories ;
import com.sun.corba.se.spi.ior.iiop.GIOPVersion ;
import com.sun.corba.se.spi.ior.iiop.IIOPAddress ;
import com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate ;
import com.sun.corba.se.spi.ior.iiop.IIOPFactories ;
import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo;
import com.sun.corba.se.spi.transport.SocketOrChannelAcceptor;
import com.sun.corba.se.spi.orb.ORB ;
import com.sun.corba.se.spi.protocol.ForwardException;
import com.sun.corba.se.spi.transport.CorbaTransportManager;
import com.sun.corba.se.spi.logging.CORBALogDomains ;
import com.sun.corba.se.impl.logging.ActivationSystemException ;
import com.sun.corba.se.impl.oa.poa.BadServerIdHandler;
import com.sun.corba.se.impl.orbutil.ORBConstants;
import com.sun.corba.se.impl.orbutil.ORBUtility;
import com.sun.corba.se.impl.util.Utility;
public class ServerManagerImpl extends _ServerManagerImplBase
implements BadServerIdHandler
{
// Using HashMap, since synchronization should be done by the calling
// routines
HashMap serverTable;
Repository repository;
CorbaTransportManager transportManager;
int initialPort;
ORB orb;
ActivationSystemException wrapper;
String dbDirName;
boolean debug = false ;
private int serverStartupDelay;
ServerManagerImpl(ORB orb, CorbaTransportManager transportManager,
Repository repository, String dbDirName, boolean debug)
{
this.orb = orb;
wrapper = ActivationSystemException.get( orb, CORBALogDomains.ORBD_ACTIVATOR ) ;
this.transportManager = transportManager; // REVISIT - NOT USED.
this.repository = repository;
this.dbDirName = dbDirName;
this.debug = debug ;
LegacyServerSocketEndPointInfo endpoint =
orb.getLegacyServerSocketManager()
.legacyGetEndpoint(LegacyServerSocketEndPointInfo.BOOT_NAMING);
initialPort = ((SocketOrChannelAcceptor)endpoint)
.getServerSocket().getLocalPort();
serverTable = new HashMap(256);
// The ServerStartupDelay is the delay added after the Server registers
// end point information. This is to allow the server to completely
// initialize after ORB is instantiated.
serverStartupDelay = ORBConstants.DEFAULT_SERVER_STARTUP_DELAY;
String delay = System.getProperty( ORBConstants.SERVER_STARTUP_DELAY);
if( delay != null ) {
try {
serverStartupDelay = Integer.parseInt( delay );
} catch ( Exception e ) {
// Just use the default 1000 milliseconds as the default
}
}
Class cls = orb.getORBData( ).getBadServerIdHandler();
if( cls == null ) {
orb.setBadServerIdHandler( this );
} else {
orb.initBadServerIdHandler() ;
}
orb.connect(this);
ProcessMonitorThread.start( serverTable );
}
public void activate(int serverId)
throws ServerAlreadyActive, ServerNotRegistered, ServerHeldDown
{
ServerLocation location;
ServerTableEntry entry;
Integer key = new Integer(serverId);
synchronized(serverTable) {
entry = (ServerTableEntry) serverTable.get(key);
}
if (entry != null && entry.isActive()) {
if (debug)
System.out.println( "ServerManagerImpl: activate for server Id " +
serverId + " failed because server is already active. " +
"entry = " + entry ) ;
throw new ServerAlreadyActive( serverId );
}
// locate the server
try {
// We call getEntry here so that state of the entry is
// checked for validity before we actually go and locate a server
entry = getEntry(serverId);
if (debug)
System.out.println( "ServerManagerImpl: locateServer called with " +
" serverId=" + serverId + " endpointType="
+ IIOP_CLEAR_TEXT.value + " block=false" ) ;
location = locateServer(entry, IIOP_CLEAR_TEXT.value, false);
if (debug)
System.out.println( "ServerManagerImpl: activate for server Id " +
serverId + " found location " +
location.hostname + " and activated it" ) ;
} catch (NoSuchEndPoint ex) {
if (debug)
System.out.println( "ServerManagerImpl: activate for server Id " +
" threw NoSuchEndpoint exception, which was ignored" );
}
}
public void active(int serverId, Server server) throws ServerNotRegistered
{
ServerTableEntry entry;
Integer key = new Integer(serverId);
synchronized (serverTable) {
entry = (ServerTableEntry) serverTable.get(key);
if (entry == null) {
if (debug)
System.out.println( "ServerManagerImpl: active for server Id " +
serverId + " called, but no such server is registered." ) ;
throw wrapper.serverNotExpectedToRegister() ;
} else {
if (debug)
System.out.println( "ServerManagerImpl: active for server Id " +
serverId + " called. This server is now active." ) ;
entry.register(server);
}
}
}
public void registerEndpoints( int serverId, String orbId,
EndPointInfo [] endpointList ) throws NoSuchEndPoint, ServerNotRegistered,
ORBAlreadyRegistered
{
// orbId is ignored for now
ServerTableEntry entry;
Integer key = new Integer(serverId);
synchronized (serverTable) {
entry = (ServerTableEntry) serverTable.get(key);
if (entry == null) {
if (debug)
System.out.println(
"ServerManagerImpl: registerEndpoint for server Id " +
serverId + " called, but no such server is registered." ) ;
throw wrapper.serverNotExpectedToRegister() ;
} else {
if (debug)
System.out.println(
"ServerManagerImpl: registerEndpoints for server Id " +
serverId + " called. This server is now active." ) ;
entry.registerPorts( orbId, endpointList );
}
}
}
public int[] getActiveServers()
{
ServerTableEntry entry;
int[] list = null;
synchronized (serverTable) {
// unlike vectors, list is not synchronized
ArrayList servers = new ArrayList(0);
Iterator serverList = serverTable.keySet().iterator();
try {
while (serverList.hasNext()) {
Integer key = (Integer) serverList.next();
// get an entry
entry = (ServerTableEntry) serverTable.get(key);
if (entry.isValid() && entry.isActive()) {
servers.add(entry);
}
}
} catch (NoSuchElementException e) {
// all done
}
// collect the active entries
list = new int[servers.size()];
for (int i = 0; i < servers.size(); i++) {
entry = (ServerTableEntry) servers.get(i);
list[i] = entry.getServerId();
}
}
if (debug) {
StringBuffer sb = new StringBuffer() ;
for (int ctr=0; ctr<list.length; ctr++) {
sb.append( ' ' ) ;
sb.append( list[ctr] ) ;
}
System.out.println( "ServerManagerImpl: getActiveServers returns" +
sb.toString() ) ;
}
return list;
}
public void shutdown(int serverId) throws ServerNotActive
{
ServerTableEntry entry;
Integer key = new Integer(serverId);
synchronized(serverTable) {
entry = (ServerTableEntry) serverTable.remove(key);
if (entry == null) {
if (debug)
System.out.println( "ServerManagerImpl: shutdown for server Id " +
serverId + " throws ServerNotActive." ) ;
throw new ServerNotActive( serverId );
}
try {
entry.destroy();
if (debug)
System.out.println( "ServerManagerImpl: shutdown for server Id " +
serverId + " completed." ) ;
} catch (Exception e) {
if (debug)
System.out.println( "ServerManagerImpl: shutdown for server Id " +
serverId + " threw exception " + e ) ;
}
}
}
private ServerTableEntry getEntry( int serverId )
throws ServerNotRegistered
{
Integer key = new Integer(serverId);
ServerTableEntry entry = null ;
synchronized (serverTable) {
entry = (ServerTableEntry) serverTable.get(key);
if (debug)
if (entry == null) {
System.out.println( "ServerManagerImpl: getEntry: " +
"no active server found." ) ;
} else {
System.out.println( "ServerManagerImpl: getEntry: " +
" active server found " + entry + "." ) ;
}
if ((entry != null) && (!entry.isValid())) {
serverTable.remove(key);
entry = null;
}
if (entry == null) {
ServerDef serverDef = repository.getServer(serverId);
entry = new ServerTableEntry( wrapper,
serverId, serverDef, initialPort, dbDirName, false, debug);
serverTable.put(key, entry);
entry.activate() ;
}
}
return entry ;
}
private ServerLocation locateServer (ServerTableEntry entry, String endpointType,
boolean block)
throws NoSuchEndPoint, ServerNotRegistered, ServerHeldDown
{
ServerLocation location = new ServerLocation() ;
// if server location is desired, then wait for the server
// to register back, then return location
ORBPortInfo [] serverORBAndPortList;
if (block) {
try {
serverORBAndPortList = entry.lookup(endpointType);
} catch (Exception ex) {
if (debug)
System.out.println( "ServerManagerImpl: locateServer: " +
"server held down" ) ;
throw new ServerHeldDown( entry.getServerId() );
}
String host =
orb.getLegacyServerSocketManager()
.legacyGetEndpoint(LegacyServerSocketEndPointInfo.DEFAULT_ENDPOINT).getHostName();
location.hostname = host ;
int listLength;
if (serverORBAndPortList != null) {
listLength = serverORBAndPortList.length;
} else {
listLength = 0;
}
location.ports = new ORBPortInfo[listLength];
for (int i = 0; i < listLength; i++) {
location.ports[i] = new ORBPortInfo(serverORBAndPortList[i].orbId,
serverORBAndPortList[i].port) ;
if (debug)
System.out.println( "ServerManagerImpl: locateServer: " +
"server located at location " +
location.hostname + " ORBid " +
serverORBAndPortList[i].orbId +
" Port " + serverORBAndPortList[i].port) ;
}
}
return location;
}
private ServerLocationPerORB locateServerForORB (ServerTableEntry entry, String orbId,
boolean block)
throws InvalidORBid, ServerNotRegistered, ServerHeldDown
{
ServerLocationPerORB location = new ServerLocationPerORB() ;
// if server location is desired, then wait for the server
// to register back, then return location
EndPointInfo [] endpointInfoList;
if (block) {
try {
endpointInfoList = entry.lookupForORB(orbId);
} catch (InvalidORBid ex) {
throw ex;
} catch (Exception ex) {
if (debug)
System.out.println( "ServerManagerImpl: locateServerForORB: " +
"server held down" ) ;
throw new ServerHeldDown( entry.getServerId() );
}
String host =
orb.getLegacyServerSocketManager()
.legacyGetEndpoint(LegacyServerSocketEndPointInfo.DEFAULT_ENDPOINT).getHostName();
location.hostname = host ;
int listLength;
if (endpointInfoList != null) {
listLength = endpointInfoList.length;
} else {
listLength = 0;
}
location.ports = new EndPointInfo[listLength];
for (int i = 0; i < listLength; i++) {
location.ports[i] = new EndPointInfo(endpointInfoList[i].endpointType,
endpointInfoList[i].port) ;
if (debug)
System.out.println( "ServerManagerImpl: locateServer: " +
"server located at location " +
location.hostname + " endpointType " +
endpointInfoList[i].endpointType +
" Port " + endpointInfoList[i].port) ;
}
}
return location;
}
public String[] getORBNames(int serverId)
throws ServerNotRegistered
{
try {
ServerTableEntry entry = getEntry( serverId ) ;
return (entry.getORBList());
} catch (Exception ex) {
throw new ServerNotRegistered(serverId);
}
}
private ServerTableEntry getRunningEntry( int serverId )
throws ServerNotRegistered
{
ServerTableEntry entry = getEntry( serverId ) ;
try {
// this is to see if the server has any listeners
ORBPortInfo [] serverORBAndPortList = entry.lookup(IIOP_CLEAR_TEXT.value) ;
} catch (Exception exc) {
return null ;
}
return entry;
}
public void install( int serverId )
throws ServerNotRegistered, ServerHeldDown, ServerAlreadyInstalled
{
ServerTableEntry entry = getRunningEntry( serverId ) ;
if (entry != null) {
repository.install( serverId ) ;
entry.install() ;
}
}
public void uninstall( int serverId )
throws ServerNotRegistered, ServerHeldDown, ServerAlreadyUninstalled
{
ServerTableEntry entry =
(ServerTableEntry) serverTable.get( new Integer(serverId) );
if (entry != null) {
entry =
(ServerTableEntry) serverTable.remove(new Integer(serverId));
if (entry == null) {
if (debug)
System.out.println( "ServerManagerImpl: shutdown for server Id " +
serverId + " throws ServerNotActive." ) ;
throw new ServerHeldDown( serverId );
}
entry.uninstall();
}
}
public ServerLocation locateServer (int serverId, String endpointType)
throws NoSuchEndPoint, ServerNotRegistered, ServerHeldDown
{
ServerTableEntry entry = getEntry( serverId ) ;
if (debug)
System.out.println( "ServerManagerImpl: locateServer called with " +
" serverId=" + serverId + " endpointType=" +
endpointType + " block=true" ) ;
// passing in entry to eliminate multiple lookups for
// the same entry in some cases
return locateServer(entry, endpointType, true);
}
/** This method is used to obtain the registered ports for an ORB.
* This is useful for custom Bad server ID handlers in ORBD.
*/
public ServerLocationPerORB locateServerForORB (int serverId, String orbId)
throws InvalidORBid, ServerNotRegistered, ServerHeldDown
{
ServerTableEntry entry = getEntry( serverId ) ;
// passing in entry to eliminate multiple lookups for
// the same entry in some cases
if (debug)
System.out.println( "ServerManagerImpl: locateServerForORB called with " +
" serverId=" + serverId + " orbId=" + orbId +
" block=true" ) ;
return locateServerForORB(entry, orbId, true);
}
public void handle(ObjectKey okey)
{
IOR newIOR = null;
ServerLocationPerORB location;
// we need to get the serverid and the orbid from the object key
ObjectKeyTemplate oktemp = okey.getTemplate();
int serverId = oktemp.getServerId() ;
String orbId = oktemp.getORBId() ;
try {
// get the ORBName corresponding to the orbMapid, that was
// first registered by the server
ServerTableEntry entry = getEntry( serverId ) ;
location = locateServerForORB(entry, orbId, true);
if (debug)
System.out.println( "ServerManagerImpl: handle called for server id" +
serverId + " orbid " + orbId) ;
// we received a list of ports corresponding to an ORB in a
// particular server, now retrieve the one corresponding
// to IIOP_CLEAR_TEXT, and for other created the tagged
// components to be added to the IOR
int clearPort = 0;
EndPointInfo[] listenerPorts = location.ports;
for (int i = 0; i < listenerPorts.length; i++) {
if ((listenerPorts[i].endpointType).equals(IIOP_CLEAR_TEXT.value)) {
clearPort = listenerPorts[i].port;
break;
}
}
// create a new IOR with the correct port and correct tagged
// components
IIOPAddress addr = IIOPFactories.makeIIOPAddress( orb,
location.hostname, clearPort ) ;
IIOPProfileTemplate iptemp =
IIOPFactories.makeIIOPProfileTemplate(
orb, GIOPVersion.V1_2, addr ) ;
if (GIOPVersion.V1_2.supportsIORIIOPProfileComponents()) {
iptemp.add(IIOPFactories.makeCodeSetsComponent(orb));
iptemp.add(IIOPFactories.makeMaxStreamFormatVersionComponent());
}
IORTemplate iortemp = IORFactories.makeIORTemplate(oktemp) ;
iortemp.add( iptemp ) ;
newIOR = iortemp.makeIOR(orb, "IDL:org/omg/CORBA/Object:1.0",
okey.getId() );
} catch (Exception e) {
throw wrapper.errorInBadServerIdHandler( e ) ;
}
if (debug)
System.out.println( "ServerManagerImpl: handle " +
"throws ForwardException" ) ;
try {
// This delay is required in case of Server is activated or
// re-activated the first time. Server needs some time before
// handling all the requests.
// (Talk to Ken to see whether there is a better way of doing this).
Thread.sleep( serverStartupDelay );
} catch ( Exception e ) {
System.out.println( "Exception = " + e );
e.printStackTrace();
}
throw new ForwardException(orb, newIOR);
}
public int getEndpoint(String endpointType) throws NoSuchEndPoint
{
return orb.getLegacyServerSocketManager()
.legacyGetTransientServerPort(endpointType);
}
public int getServerPortForType(ServerLocationPerORB location,
String endPointType)
throws NoSuchEndPoint
{
EndPointInfo[] listenerPorts = location.ports;
for (int i = 0; i < listenerPorts.length; i++) {
if ((listenerPorts[i].endpointType).equals(endPointType)) {
return listenerPorts[i].port;
}
}
throw new NoSuchEndPoint();
}
}

View file

@ -1,543 +0,0 @@
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.activation;
/**
*
* @author Anita Jindal
* @since JDK1.2
*/
import org.omg.CORBA.CompletionStatus;
import com.sun.corba.se.spi.activation.Server;
import com.sun.corba.se.spi.activation.EndPointInfo;
import com.sun.corba.se.spi.activation.ORBAlreadyRegistered;
import com.sun.corba.se.spi.activation.ORBPortInfo;
import com.sun.corba.se.spi.activation.InvalidORBid;
import com.sun.corba.se.spi.activation.ServerHeldDown;
import com.sun.corba.se.spi.activation.RepositoryPackage.ServerDef;
import com.sun.corba.se.spi.activation.IIOP_CLEAR_TEXT;
import com.sun.corba.se.spi.orb.ORB ;
import com.sun.corba.se.impl.orbutil.ORBConstants;
import com.sun.corba.se.impl.logging.ActivationSystemException ;
import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.NoSuchElementException;
public class ServerTableEntry
{
private final static int DE_ACTIVATED = 0;
private final static int ACTIVATING = 1;
private final static int ACTIVATED = 2;
private final static int RUNNING = 3;
private final static int HELD_DOWN = 4;
private String printState()
{
String str = "UNKNOWN";
switch (state) {
case (DE_ACTIVATED) : str = "DE_ACTIVATED"; break;
case (ACTIVATING ) : str = "ACTIVATING "; break;
case (ACTIVATED ) : str = "ACTIVATED "; break;
case (RUNNING ) : str = "RUNNING "; break;
case (HELD_DOWN ) : str = "HELD_DOWN "; break;
default: break;
}
return str;
}
private final static long waitTime = 2000;
private static final int ActivationRetryMax = 5;
// state of each entry
private int state;
private int serverId;
private HashMap orbAndPortInfo;
private Server serverObj;
private ServerDef serverDef;
private Process process;
private int activateRetryCount=0;
private String activationCmd;
private ActivationSystemException wrapper ;
public String toString()
{
return "ServerTableEntry[" + "state=" + printState() +
" serverId=" + serverId +
" activateRetryCount=" + activateRetryCount + "]" ;
}
// get the string needed to make the activation command
private static String javaHome, classPath, fileSep, pathSep;
static {
javaHome = System.getProperty("java.home");
classPath = System.getProperty("java.class.path");
fileSep = System.getProperty("file.separator");
pathSep = System.getProperty("path.separator");
}
ServerTableEntry( ActivationSystemException wrapper,
int serverId, ServerDef serverDef, int initialPort,
String dbDirName, boolean verify, boolean debug )
{
this.wrapper = wrapper ;
this.serverId = serverId;
this.serverDef = serverDef;
this.debug = debug ;
// create a HashMap with capacity 255
// Since all methods are synchronized, we don't need any
// additional synchronization mechanisms
orbAndPortInfo = new HashMap(255);
activateRetryCount = 0;
state = ACTIVATING;
// compute the activation command
activationCmd =
// add path to the java vm
javaHome + fileSep + "bin" + fileSep + "java " +
// add any arguments to the server Java VM
serverDef.serverVmArgs + " " +
// add ORB properties
"-Dioser=" + System.getProperty( "ioser" ) + " " +
"-D" + ORBConstants.INITIAL_PORT_PROPERTY + "=" + initialPort + " " +
"-D" + ORBConstants.DB_DIR_PROPERTY + "=" + dbDirName + " " +
"-D" + ORBConstants.ACTIVATED_PROPERTY + "=true " +
"-D" + ORBConstants.SERVER_ID_PROPERTY + "=" + serverId + " " +
"-D" + ORBConstants.SERVER_NAME_PROPERTY + "=" + serverDef.serverName + " " +
// we need to pass in the verify flag, so that the server is not
// launched, when we try to validate its definition during registration
// into the RepositoryImpl
(verify ? "-D" + ORBConstants.SERVER_DEF_VERIFY_PROPERTY + "=true ": "") +
// add classpath to the server
"-classpath " + classPath +
(serverDef.serverClassPath.equals("") == true ? "" : pathSep) +
serverDef.serverClassPath +
// add server class name and arguments
" com.sun.corba.se.impl.activation.ServerMain " + serverDef.serverArgs
// Add the debug flag, if any
+ (debug ? " -debug" : "") ;
if (debug) System.out.println(
"ServerTableEntry constructed with activation command " +
activationCmd);
}
/**
* Verify whether the server definition is valid.
*/
public int verify()
{
try {
if (debug)
System.out.println("Server being verified w/" + activationCmd);
process = Runtime.getRuntime().exec(activationCmd);
int result = process.waitFor();
if (debug)
printDebug( "verify", "returns " + ServerMain.printResult( result ) ) ;
return result ;
} catch (Exception e) {
if (debug)
printDebug( "verify", "returns unknown error because of exception " +
e ) ;
return ServerMain.UNKNOWN_ERROR;
}
}
private void printDebug(String method, String msg)
{
System.out.println("ServerTableEntry: method =" + method);
System.out.println("ServerTableEntry: server =" + serverId);
System.out.println("ServerTableEntry: state =" + printState());
System.out.println("ServerTableEntry: message =" + msg);
System.out.println();
}
synchronized void activate() throws org.omg.CORBA.SystemException
{
state = ACTIVATED;
try {
if (debug)
printDebug("activate", "activating server");
process = Runtime.getRuntime().exec(activationCmd);
} catch (Exception e) {
deActivate();
if (debug)
printDebug("activate", "throwing premature process exit");
throw wrapper.unableToStartProcess() ;
}
}
synchronized void register(Server server)
{
if (state == ACTIVATED) {
serverObj = server;
//state = RUNNING;
//notifyAll();
if (debug)
printDebug("register", "process registered back");
} else {
if (debug)
printDebug("register", "throwing premature process exit");
throw wrapper.serverNotExpectedToRegister() ;
}
}
synchronized void registerPorts( String orbId, EndPointInfo [] endpointList)
throws ORBAlreadyRegistered
{
// find if the ORB is already registered, then throw an exception
if (orbAndPortInfo.containsKey(orbId)) {
throw new ORBAlreadyRegistered(orbId);
}
// store all listener ports and their types
int numListenerPorts = endpointList.length;
EndPointInfo [] serverListenerPorts = new EndPointInfo[numListenerPorts];
for (int i = 0; i < numListenerPorts; i++) {
serverListenerPorts[i] = new EndPointInfo (endpointList[i].endpointType, endpointList[i].port);
if (debug)
System.out.println("registering type: " + serverListenerPorts[i].endpointType + " port " + serverListenerPorts[i].port);
}
// put this set of listener ports in the HashMap associated
// with the orbId
orbAndPortInfo.put(orbId, serverListenerPorts);
if (state == ACTIVATED) {
state = RUNNING;
notifyAll();
}
// _REVISIT_, If the state is not equal to ACTIVATED then it is a bug
// need to log that error, once the Logging framework is in place
// for rip-int.
if (debug)
printDebug("registerPorts", "process registered Ports");
}
void install()
{
Server localServerObj = null;
synchronized ( this ) {
if (state == RUNNING)
localServerObj = serverObj;
else
throw wrapper.serverNotRunning() ;
}
if (localServerObj != null) {
localServerObj.install() ;
}
}
void uninstall()
{
Server localServerObj = null;
Process localProcess = null;
synchronized (this) {
localServerObj = serverObj;
localProcess = process;
if (state == RUNNING) {
deActivate();
} else {
throw wrapper.serverNotRunning() ;
}
}
try {
if (localServerObj != null) {
localServerObj.shutdown(); // shutdown the server
localServerObj.uninstall() ; // call the uninstall
}
if (localProcess != null) {
localProcess.destroy();
}
} catch (Exception ex) {
// what kind of exception should be thrown
}
}
synchronized void holdDown()
{
state = HELD_DOWN;
if (debug)
printDebug( "holdDown", "server held down" ) ;
notifyAll();
}
synchronized void deActivate()
{
state = DE_ACTIVATED;
if (debug)
printDebug( "deActivate", "server deactivated" ) ;
notifyAll();
}
synchronized void checkProcessHealth( ) {
// If the State in the ServerTableEntry is RUNNING and the
// Process was shut down abnormally, The method will change the
// server state as De-Activated.
if( state == RUNNING ) {
try {
int exitVal = process.exitValue();
} catch (IllegalThreadStateException e1) {
return;
}
synchronized ( this ) {
// Clear the PortInformation as it is old
orbAndPortInfo.clear();
// Move the state to De-Activated, So that the next
// call to this server will re-activate.
deActivate();
}
}
}
synchronized boolean isValid()
{
if ((state == ACTIVATING) || (state == HELD_DOWN)) {
if (debug)
printDebug( "isValid", "returns true" ) ;
return true;
}
try {
int exitVal = process.exitValue();
} catch (IllegalThreadStateException e1) {
return true;
}
if (state == ACTIVATED) {
if (activateRetryCount < ActivationRetryMax) {
if (debug)
printDebug("isValid", "reactivating server");
activateRetryCount++;
activate();
return true;
}
if (debug)
printDebug("isValid", "holding server down");
holdDown();
return true;
}
deActivate();
return false;
}
synchronized ORBPortInfo[] lookup(String endpointType) throws ServerHeldDown
{
while ((state == ACTIVATING) || (state == ACTIVATED)) {
try {
wait(waitTime);
if (!isValid()) break;
} catch(Exception e) {}
}
ORBPortInfo[] orbAndPortList = null;
if (state == RUNNING) {
orbAndPortList = new ORBPortInfo[orbAndPortInfo.size()];
Iterator setORBids = orbAndPortInfo.keySet().iterator();
try {
int numElements = 0;
int i;
int port;
while (setORBids.hasNext()) {
String orbId = (String) setORBids.next();
// get an entry corresponding to orbId
EndPointInfo [] serverListenerPorts = (EndPointInfo []) orbAndPortInfo.get(orbId);
port = -1;
// return the port corresponding to the endpointType
for (i = 0; i < serverListenerPorts.length; i++) {
if (debug)
System.out.println("lookup num-ports " + serverListenerPorts.length + " " +
serverListenerPorts[i].endpointType + " " +
serverListenerPorts[i].port );
if ((serverListenerPorts[i].endpointType).equals(endpointType)) {
port = serverListenerPorts[i].port;
break;
}
}
orbAndPortList[numElements] = new ORBPortInfo(orbId, port);
numElements++;
}
} catch (NoSuchElementException e) {
// have everything in the table
}
return orbAndPortList;
}
if (debug)
printDebug("lookup", "throwing server held down error");
throw new ServerHeldDown( serverId ) ;
}
synchronized EndPointInfo[] lookupForORB(String orbId)
throws ServerHeldDown, InvalidORBid
{
while ((state == ACTIVATING) || (state == ACTIVATED)) {
try {
wait(waitTime);
if (!isValid()) break;
} catch(Exception e) {}
}
EndPointInfo[] portList = null;
if (state == RUNNING) {
try {
// get an entry corresponding to orbId
EndPointInfo [] serverListenerPorts = (EndPointInfo []) orbAndPortInfo.get(orbId);
portList = new EndPointInfo[serverListenerPorts.length];
// return the port corresponding to the endpointType
for (int i = 0; i < serverListenerPorts.length; i++) {
if (debug)
System.out.println("lookup num-ports " + serverListenerPorts.length + " "
+ serverListenerPorts[i].endpointType + " " +
serverListenerPorts[i].port );
portList[i] = new EndPointInfo(serverListenerPorts[i].endpointType, serverListenerPorts[i].port);
}
} catch (NoSuchElementException e) {
// no element in HashMap corresponding to ORBid found
throw new InvalidORBid();
}
return portList;
}
if (debug)
printDebug("lookup", "throwing server held down error");
throw new ServerHeldDown( serverId ) ;
}
synchronized String[] getORBList()
{
String [] orbList = new String[orbAndPortInfo.size()];
Iterator setORBids = orbAndPortInfo.keySet().iterator();
try {
int numElements = 0;
while (setORBids.hasNext()) {
String orbId = (String) setORBids.next();
orbList[numElements++] = orbId ;
}
} catch (NoSuchElementException e) {
// have everything in the table
}
return orbList;
}
int getServerId()
{
return serverId;
}
boolean isActive()
{
return (state == RUNNING) || (state == ACTIVATED);
}
synchronized void destroy()
{
Server localServerObj = null;
Process localProcess = null;
synchronized (this) {
localServerObj = serverObj;
localProcess = process;
deActivate();
}
try {
if (localServerObj != null)
localServerObj.shutdown();
if (debug)
printDebug( "destroy", "server shutdown successfully" ) ;
} catch (Exception ex) {
if (debug)
printDebug( "destroy",
"server shutdown threw exception" + ex ) ;
// ex.printStackTrace();
}
try {
if (localProcess != null)
localProcess.destroy();
if (debug)
printDebug( "destroy", "process destroyed successfully" ) ;
} catch (Exception ex) {
if (debug)
printDebug( "destroy",
"process destroy threw exception" + ex ) ;
// ex.printStackTrace();
}
}
private boolean debug = false;
}

View file

@ -1,973 +0,0 @@
/*
* Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.activation;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Vector;
import java.util.Properties;
import java.util.StringTokenizer;
import org.omg.CORBA.ORB;
import org.omg.CORBA.INITIALIZE;
import org.omg.CORBA.CompletionStatus;
import com.sun.corba.se.impl.orbutil.ORBConstants;
import com.sun.corba.se.impl.orbutil.CorbaResourceUtil;
import com.sun.corba.se.spi.activation.*;
import com.sun.corba.se.spi.activation.ServerHeldDown;
import com.sun.corba.se.spi.activation.RepositoryPackage.ServerDef;
import com.sun.corba.se.spi.activation.LocatorPackage.ServerLocation;
import com.sun.corba.se.spi.activation.LocatorPackage.ServerLocationPerORB;
/**
*
* @author Anita Jindal
* @since JDK1.3
*/
public class ServerTool
{
final static String helpCommand = "help";
final static String toolName = "servertool";
final static String commandArg = "-cmd";
static int getServerIdForAlias( ORB orb, String applicationName ) throws ServerNotRegistered
{
try {
Repository rep = RepositoryHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_REPOSITORY_NAME ) ) ;
int serverid = rep.getServerID(applicationName);
return rep.getServerID( applicationName ) ;
} catch (Exception ex) {
throw (new ServerNotRegistered());
}
}
void run(String[] args)
{
String[] cmd = null;
// if command specified in the args, get it
for (int i=0; i < args.length; i++) {
if (args[i].equals(commandArg)) {
// get the command
int cmdLen = args.length - i - 1;
cmd = new String[cmdLen];
for (int j=0; j < cmdLen; j++) cmd[j] = args[++i];
break;
}
}
try {
// create the POA ORB
Properties props = System.getProperties() ;
props.put("org.omg.CORBA.ORBClass",
"com.sun.corba.se.impl.orb.ORBImpl" );
orb = (ORB) ORB.init(args, props);
// if command specified in the args, process it
if (cmd != null) executeCommand(cmd);
else { // process commands interactively
// create a buffered reader to read commands from standard in
BufferedReader in = new
BufferedReader(new InputStreamReader(System.in));
// print tool banner
System.out.println(CorbaResourceUtil.getText("servertool.banner"));
// process commands until user quits
while (true) {
cmd = readCommand(in);
if (cmd != null) executeCommand(cmd);
else printAvailableCommands();
}
}
} catch (Exception ex) {
System.out.println(CorbaResourceUtil.getText("servertool.usage", "servertool"));
System.out.println();
ex.printStackTrace();
}
}
public static void main(String[] args)
{
ServerTool tool = new ServerTool();
tool.run(args);
}
String[] readCommand(BufferedReader in)
{
System.out.print(toolName + " > ");
try {
int i = 0;
String cmd[] = null;
String cmdLine = in.readLine();
if (cmdLine != null) {
StringTokenizer st = new StringTokenizer(cmdLine);
if (st.countTokens() != 0) {
cmd = new String[st.countTokens()];
while (st.hasMoreTokens()) cmd[i++] = st.nextToken();
}
}
return cmd;
} catch (Exception ex) {
System.out.println(CorbaResourceUtil.getText("servertool.usage", "servertool"));
System.out.println();
ex.printStackTrace();
}
return null;
}
void printAvailableCommands()
{
CommandHandler handler;
// print short help
System.out.println(CorbaResourceUtil.getText("servertool.shorthelp"));
for (int i=0; i < handlers.size(); i++) {
handler = (CommandHandler) handlers.elementAt(i);
System.out.print("\t" + handler.getCommandName());
for (int j=handler.getCommandName().length();
j < maxNameLen; j++) System.out.print(" ");
System.out.print(" - ");
handler.printCommandHelp(System.out,
CommandHandler.shortHelp);
}
System.out.println();
}
void executeCommand(String[] cmd)
{
boolean result;
CommandHandler handler;
// handle the help command
if (cmd[0].equals(helpCommand)) {
if (cmd.length == 1) printAvailableCommands();
else {
// print long help for a specific command
for (int i=0; i < handlers.size(); i++) {
handler = (CommandHandler) handlers.elementAt(i);
if (handler.getCommandName().equals(cmd[1])) {
handler.printCommandHelp(System.out,
CommandHandler.longHelp);
}
}
}
return;
}
// determine the subcommand and execute it
for (int i=0; i < handlers.size(); i++) {
handler = (CommandHandler) handlers.elementAt(i);
if (handler.getCommandName().equals(cmd[0])) {
String[] cmdArgs = new String[cmd.length - 1];
// construct args to the command
for (int j=0; j < cmdArgs.length; j++)
cmdArgs[j] = cmd[j+1];
// execute the command
try {
System.out.println();
result = handler.processCommand(cmdArgs, orb, System.out);
if (result == CommandHandler.parseError) {
handler.printCommandHelp(System.out,
CommandHandler.longHelp);
}
System.out.println();
} catch (Exception ex) {}
return;
}
}
// unknown command - print available commands
printAvailableCommands();
}
final private static boolean debug = false;
ORB orb = null;
static Vector handlers;
static int maxNameLen;
static {
handlers = new Vector();
handlers.addElement(new RegisterServer());
handlers.addElement(new UnRegisterServer());
handlers.addElement(new GetServerID());
handlers.addElement(new ListServers());
handlers.addElement(new ListAliases());
handlers.addElement(new ListActiveServers());
handlers.addElement(new LocateServer());
handlers.addElement(new LocateServerForORB());
handlers.addElement(new ListORBs());
handlers.addElement(new ShutdownServer());
handlers.addElement(new StartServer());
handlers.addElement(new Help());
handlers.addElement(new Quit());
// determine longest command name
maxNameLen = 0;
int cmdNameLen;
for (int i=0; i < handlers.size(); i++) {
CommandHandler handler = (CommandHandler) handlers.elementAt(i);
cmdNameLen = handler.getCommandName().length();
if (cmdNameLen > maxNameLen) maxNameLen = cmdNameLen;
}
}
}
class RegisterServer implements CommandHandler
{
public String getCommandName() {return "register";}
public void printCommandHelp(PrintStream out, boolean helpType)
{
if (helpType == longHelp) {
out.println(CorbaResourceUtil.getText("servertool.register"));
} else {
out.println(CorbaResourceUtil.getText("servertool.register1"));
}
}
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out)
{
int i=0;
String applicationName = "";
String name = "";
String classpath = "";
String args = "";
String vmargs = "";
int serverId = 0;
// parse register server command
String arg;
while (i < cmdArgs.length) {
arg = cmdArgs[i++];
if (arg.equals("-server")) {
if (i < cmdArgs.length) name = cmdArgs[i++];
else return parseError;
} else if (arg.equals("-applicationName")) {
if (i < cmdArgs.length) applicationName = cmdArgs[i++];
else return parseError;
} else if (arg.equals("-classpath")) {
if (i < cmdArgs.length) classpath = cmdArgs[i++];
else return parseError;
} else if (arg.equals("-args")) {
while ((i < cmdArgs.length) && !cmdArgs[i].equals("-vmargs")){
args = args.equals("") ? cmdArgs[i] :
args + " " + cmdArgs[i];
i++;
}
if (args.equals("")) return parseError;
} else if (arg.equals("-vmargs")) {
while ((i < cmdArgs.length) && !cmdArgs[i].equals("-args")){
vmargs = vmargs.equals("") ? cmdArgs[i] :
vmargs + " " + cmdArgs[i];
i++;
}
if (vmargs.equals("")) return parseError;
} else return parseError;
}
// minimally the server class name has to be specified
if (name.equals("")) return parseError;
// register server and activate it
try {
// register the server with the repository
Repository repository = RepositoryHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_REPOSITORY_NAME ));
ServerDef server = new ServerDef(applicationName, name, classpath, args, vmargs);
serverId = repository.registerServer(server);
// activate the server
Activator activator = ActivatorHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_ACTIVATOR_NAME ));
activator.activate(serverId);
activator.install(serverId);
// print success message
out.println(CorbaResourceUtil.getText("servertool.register2", serverId));
} catch (ServerNotRegistered ex) {
} catch (ServerAlreadyActive ex) {
} catch (ServerHeldDown ex) {
out.println(CorbaResourceUtil.getText("servertool.register3", serverId));
} catch (ServerAlreadyRegistered ex) {
out.println(CorbaResourceUtil.getText("servertool.register4", serverId));
} catch (BadServerDefinition ex) {
out.println(CorbaResourceUtil.getText("servertool.baddef", ex.reason));
} catch (Exception ex) {
ex.printStackTrace();
}
return commandDone;
}
}
class UnRegisterServer implements CommandHandler
{
public String getCommandName() {return "unregister";}
public void printCommandHelp(PrintStream out, boolean helpType)
{
if (helpType == longHelp) {
out.println(CorbaResourceUtil.getText("servertool.unregister"));
} else {
out.println(CorbaResourceUtil.getText("servertool.unregister1"));
}
}
final static int illegalServerId = -1;
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out)
{
int serverId = illegalServerId;
try {
if (cmdArgs.length == 2) {
if (cmdArgs[0].equals("-serverid"))
serverId = (Integer.valueOf(cmdArgs[1])).intValue();
else if (cmdArgs[0].equals("-applicationName"))
serverId = ServerTool.getServerIdForAlias( orb, cmdArgs[1] ) ;
}
// the server id has to be specified
if (serverId == illegalServerId)
return parseError;
// deactivate server, hold it down and and unregister it
// deactivate the server
try {
Activator activator = ActivatorHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_ACTIVATOR_NAME ));
activator.uninstall(serverId);
} catch (ServerHeldDown ex) {}
// unregister the server from the repository
Repository repository = RepositoryHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_REPOSITORY_NAME ));
repository.unregisterServer(serverId);
// print success message
out.println(CorbaResourceUtil.getText("servertool.unregister2"));
} catch (ServerNotRegistered ex) {
out.println(CorbaResourceUtil.getText("servertool.nosuchserver"));
} catch (Exception ex) {
ex.printStackTrace();
}
return commandDone;
}
}
class LocateServer implements CommandHandler
{
public String getCommandName() {return "locate";}
public void printCommandHelp(PrintStream out, boolean helpType)
{
if (helpType == longHelp) {
out.println(CorbaResourceUtil.getText("servertool.locate"));
} else {
out.println(CorbaResourceUtil.getText("servertool.locate1"));
}
}
final static int illegalServerId = -1;
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out)
{
int serverId = illegalServerId;
String endPointType = IIOP_CLEAR_TEXT.value;
try {
// parse command
String arg;
int i = 0;
while (i < cmdArgs.length) {
arg = cmdArgs[i++];
if (arg.equals("-serverid")) {
if (i < cmdArgs.length)
serverId = (Integer.valueOf(cmdArgs[i++])).intValue();
else
return parseError;
} else if (arg.equals("-applicationName")) {
if (i < cmdArgs.length)
serverId = ServerTool.getServerIdForAlias( orb, cmdArgs[i++] ) ;
else
return parseError;
} else if (arg.equals("-endpointType")) {
if (i < cmdArgs.length)
endPointType = cmdArgs[i++];
}
}
// the server id has to be specified
if (serverId == illegalServerId)
return parseError;
// locate the server
// deactivate the server
Locator locator = LocatorHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_LOCATOR_NAME ));
ServerLocation location = locator.locateServer(serverId, endPointType);
// print success message
out.println(CorbaResourceUtil.getText("servertool.locate2", location.hostname));
int numEntries = location.ports.length;
for (i = 0; i < numEntries; i++) {
ORBPortInfo orbPort = location.ports[i];
out.println("\t\t"+ orbPort.port + "\t\t" + endPointType + "\t\t" + orbPort.orbId );
}
} catch (NoSuchEndPoint ex) {
} catch (ServerHeldDown ex) {
out.println(CorbaResourceUtil.getText("servertool.helddown"));
} catch (ServerNotRegistered ex) {
out.println(CorbaResourceUtil.getText("servertool.nosuchserver"));
} catch (Exception ex) {
ex.printStackTrace();
}
return commandDone;
}
}
class LocateServerForORB implements CommandHandler
{
public String getCommandName() {return "locateperorb";}
public void printCommandHelp(PrintStream out, boolean helpType)
{
if (helpType == longHelp) {
out.println(CorbaResourceUtil.getText("servertool.locateorb"));
} else {
out.println(CorbaResourceUtil.getText("servertool.locateorb1"));
}
}
final static int illegalServerId = -1;
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out)
{
int serverId = illegalServerId;
String orbId = "";
try {
// parse command
String arg;
int i = 0;
while (i < cmdArgs.length) {
arg = cmdArgs[i++];
if (arg.equals("-serverid")) {
if (i < cmdArgs.length)
serverId = (Integer.valueOf(cmdArgs[i++])).intValue();
else
return parseError;
} else if (arg.equals("-applicationName")) {
if (i < cmdArgs.length)
serverId = ServerTool.getServerIdForAlias( orb, cmdArgs[i++] ) ;
else
return parseError;
} else if (arg.equals("-orbid")) {
if (i < cmdArgs.length)
orbId = cmdArgs[i++];
}
}
// the server id has to be specified
if (serverId == illegalServerId)
return parseError;
// locate the server
// deactivate the server
Locator locator = LocatorHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_LOCATOR_NAME ));
ServerLocationPerORB location = locator.locateServerForORB(serverId,
orbId);
// print success message
out.println(CorbaResourceUtil.getText("servertool.locateorb2", location.hostname));
int numEntries = location.ports.length;
for (i = 0; i < numEntries; i++) {
EndPointInfo Port = location.ports[i];
out.println("\t\t"+ Port.port + "\t\t" + Port.endpointType + "\t\t" + orbId );
}
} catch (InvalidORBid ex) {
out.println(CorbaResourceUtil.getText("servertool.nosuchorb"));
} catch (ServerHeldDown ex) {
out.println(CorbaResourceUtil.getText("servertool.helddown"));
} catch (ServerNotRegistered ex) {
out.println(CorbaResourceUtil.getText("servertool.nosuchserver"));
} catch (Exception ex) {
ex.printStackTrace();
}
return commandDone;
}
}
class GetServerID implements CommandHandler
{
public String getCommandName() {return "getserverid" ; }
public void printCommandHelp( PrintStream out, boolean helpType )
{
if (helpType == longHelp) {
out.println(CorbaResourceUtil.getText("servertool.getserverid"));
} else {
out.println(CorbaResourceUtil.getText("servertool.getserverid1"));
}
}
public boolean processCommand( String[] cmdArgs, ORB orb, PrintStream out )
{
if ((cmdArgs.length == 2) && cmdArgs[0].equals( "-applicationName" )) {
String str = (String)cmdArgs[1] ;
try {
Repository repository = RepositoryHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_REPOSITORY_NAME ));
try {
int result = repository.getServerID( str ) ;
out.println() ;
out.println(CorbaResourceUtil.getText("servertool.getserverid2", str, Integer.toString(result)));
out.println() ;
} catch (ServerNotRegistered e) {
out.println(CorbaResourceUtil.getText("servertool.nosuchserver"));
}
} catch (Exception ex) {
ex.printStackTrace() ;
}
return commandDone ;
} else
return parseError ;
}
}
class ListServers implements CommandHandler
{
public String getCommandName() {return "list";}
public void printCommandHelp(PrintStream out, boolean helpType)
{
if (helpType == longHelp) {
out.println(CorbaResourceUtil.getText("servertool.list"));
} else {
out.println(CorbaResourceUtil.getText("servertool.list1"));
}
}
final static int illegalServerId = -1;
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out)
{
int serverId = illegalServerId;
boolean listOneServer = false;
ServerDef serverDef;
// determine if list single server or all servers
listOneServer = (cmdArgs.length!=0) ;
if ((cmdArgs.length == 2) && cmdArgs[0].equals("-serverid"))
serverId = (Integer.valueOf(cmdArgs[1])).intValue();
if ((serverId == illegalServerId) && listOneServer)
return parseError;
// process the list server command
try {
Repository repository = RepositoryHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_REPOSITORY_NAME ));
if (listOneServer) {
try {
serverDef = repository.getServer(serverId);
out.println();
printServerDef(serverDef, serverId, out);
out.println();
} catch (ServerNotRegistered e) {
out.println(CorbaResourceUtil.getText("servertool.nosuchserver"));
}
} else {
int[] servers = repository.listRegisteredServers();
out.println(CorbaResourceUtil.getText("servertool.list2"));
sortServers(servers);
for (int i=0; i < servers.length; i++) {
try {
serverDef = repository.getServer(servers[i]);
out.println("\t " + servers[i] + "\t\t" +
serverDef.serverName + "\t\t"
+ serverDef.applicationName);
} catch (ServerNotRegistered e) {}
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return commandDone;
}
static void printServerDef(ServerDef serverDef, int serverId,
PrintStream out)
{
out.println(CorbaResourceUtil.getText("servertool.appname", serverDef.applicationName));
out.println(CorbaResourceUtil.getText("servertool.name", serverDef.serverName));
out.println(CorbaResourceUtil.getText("servertool.classpath", serverDef.serverClassPath));
out.println(CorbaResourceUtil.getText("servertool.args", serverDef.serverArgs));
out.println(CorbaResourceUtil.getText("servertool.vmargs", serverDef.serverVmArgs));
out.println(CorbaResourceUtil.getText("servertool.serverid", serverId));
}
/**
* Do a simple bubble sort to sort the server ids in ascending
* order.
*/
static void sortServers(int[] serverIds)
{
int size = serverIds.length;
int lowest;
for (int i=0; i < size; i++) {
lowest = i;
for (int j=i+1; j < size; j++) {
if (serverIds[j] < serverIds[lowest]) lowest = j;
}
if (lowest != i) {
int temp = serverIds[i];
serverIds[i] = serverIds[lowest];
serverIds[lowest] = temp;
}
}
}
}
class ListActiveServers implements CommandHandler
{
public String getCommandName() {return "listactive";}
public void printCommandHelp(PrintStream out, boolean helpType)
{
if (helpType == longHelp) {
out.println(CorbaResourceUtil.getText("servertool.listactive"));
} else {
out.println(CorbaResourceUtil.getText("servertool.listactive1"));
}
}
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out)
{
ServerDef serverDef;
// process the list active servers command
try {
Repository repository = RepositoryHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_REPOSITORY_NAME ));
Activator activator = ActivatorHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_ACTIVATOR_NAME ));
int[] servers = activator.getActiveServers();
out.println(CorbaResourceUtil.getText("servertool.list2"));
ListServers.sortServers(servers);
for (int i=0; i < servers.length; i++) {
try {
serverDef = repository.getServer(servers[i]);
out.println("\t " + servers[i] + "\t\t" +
serverDef.serverName + "\t\t" +
serverDef.applicationName);
} catch (ServerNotRegistered e) {}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return commandDone;
}
}
class ListAliases implements CommandHandler
{
public String getCommandName() {return "listappnames";}
public void printCommandHelp(PrintStream out, boolean helpType)
{
if (helpType == longHelp) {
out.println(CorbaResourceUtil.getText("servertool.listappnames"));
} else {
out.println(CorbaResourceUtil.getText("servertool.listappnames1"));
}
}
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out)
{
try {
Repository repository = RepositoryHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_REPOSITORY_NAME ));
String[] applicationNames = repository.getApplicationNames();
out.println(CorbaResourceUtil.getText("servertool.listappnames2"));
out.println();
for (int i=0; i < applicationNames.length; i++)
out.println( "\t" + applicationNames[i] ) ;
} catch (Exception ex) {
ex.printStackTrace();
}
return commandDone;
}
}
class ShutdownServer implements CommandHandler
{
public String getCommandName() {return "shutdown";}
public void printCommandHelp(PrintStream out, boolean helpType)
{
if (helpType == longHelp) {
out.println(CorbaResourceUtil.getText("servertool.shutdown"));
} else {
out.println(CorbaResourceUtil.getText("servertool.shutdown1"));
}
}
final static int illegalServerId = -1;
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out)
{
int serverId = illegalServerId;
try {
// determine the server id
if (cmdArgs.length == 2)
if (cmdArgs[0].equals("-serverid"))
serverId = (Integer.valueOf(cmdArgs[1])).intValue();
else if (cmdArgs[0].equals("-applicationName"))
serverId = ServerTool.getServerIdForAlias( orb, cmdArgs[1] ) ;
if (serverId == illegalServerId)
return parseError;
// shutdown the server
Activator activator = ActivatorHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_ACTIVATOR_NAME ));
activator.shutdown(serverId);
out.println(CorbaResourceUtil.getText("servertool.shutdown2"));
} catch (ServerNotActive ex) {
out.println(CorbaResourceUtil.getText("servertool.servernotrunning"));
} catch (ServerNotRegistered ex) {
out.println(CorbaResourceUtil.getText("servertool.nosuchserver"));
} catch (Exception ex) {
ex.printStackTrace();
}
return commandDone;
}
}
class StartServer implements CommandHandler
{
public String getCommandName() {return "startup";}
public void printCommandHelp(PrintStream out, boolean helpType)
{
if (helpType == longHelp) {
out.println(CorbaResourceUtil.getText("servertool.startserver"));
} else {
out.println(CorbaResourceUtil.getText("servertool.startserver1"));
}
}
final static int illegalServerId = -1;
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out)
{
int serverId = illegalServerId;
try {
// determine the server id
if (cmdArgs.length == 2)
if (cmdArgs[0].equals("-serverid"))
serverId = (Integer.valueOf(cmdArgs[1])).intValue();
else if (cmdArgs[0].equals("-applicationName"))
serverId = ServerTool.getServerIdForAlias( orb, cmdArgs[1] ) ;
if (serverId == illegalServerId)
return parseError;
// startup the server
Activator activator = ActivatorHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_ACTIVATOR_NAME ));
activator.activate(serverId);
out.println(CorbaResourceUtil.getText("servertool.startserver2"));
} catch (ServerNotRegistered ex) {
out.println(CorbaResourceUtil.getText("servertool.nosuchserver"));
} catch (ServerAlreadyActive ex) {
out.println(CorbaResourceUtil.getText("servertool.serverup"));
} catch (ServerHeldDown ex) {
out.println(CorbaResourceUtil.getText("servertool.helddown"));
} catch (Exception ex) {
ex.printStackTrace();
}
return commandDone;
}
}
class Quit implements CommandHandler
{
public String getCommandName() {return "quit";}
public void printCommandHelp(PrintStream out, boolean helpType)
{
if (helpType == longHelp) {
out.println(CorbaResourceUtil.getText("servertool.quit"));
} else {
out.println(CorbaResourceUtil.getText("servertool.quit1"));
}
}
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out)
{
System.exit(0);
return commandDone;
}
}
class Help implements CommandHandler
{
public String getCommandName() {return "help";}
public void printCommandHelp(PrintStream out, boolean helpType)
{
if (helpType == longHelp) {
out.println(CorbaResourceUtil.getText("servertool.help"));
} else {
out.println(CorbaResourceUtil.getText("servertool.help1"));
}
}
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out)
{
return commandDone;
}
}
class ListORBs implements CommandHandler
{
public String getCommandName() {return "orblist";}
public void printCommandHelp(PrintStream out, boolean helpType)
{
if (helpType == longHelp) {
out.println(CorbaResourceUtil.getText("servertool.orbidmap"));
} else {
out.println(CorbaResourceUtil.getText("servertool.orbidmap1"));
}
}
final static int illegalServerId = -1;
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out)
{
int serverId = illegalServerId;
try {
if (cmdArgs.length == 2) {
if (cmdArgs[0].equals("-serverid"))
serverId = (Integer.valueOf(cmdArgs[1])).intValue();
else if (cmdArgs[0].equals("-applicationName"))
serverId = ServerTool.getServerIdForAlias( orb, cmdArgs[1] ) ;
}
// the server id has to be specified
if (serverId == illegalServerId)
return parseError;
// activate the server
Activator activator = ActivatorHelper.narrow(
orb.resolve_initial_references( ORBConstants.SERVER_ACTIVATOR_NAME ));
String[] orbList = activator.getORBNames(serverId);
out.println(CorbaResourceUtil.getText("servertool.orbidmap2"));
for (int i = 0; i < orbList.length ; i++) {
out.println("\t "+ orbList[i]);
}
} catch (ServerNotRegistered ex) {
out.println("\tno such server found.");
} catch (Exception ex) {
ex.printStackTrace();
}
return commandDone;
}
}

View file

@ -1,73 +0,0 @@
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.copyobject ;
import com.sun.corba.se.spi.orb.ORB ;
import com.sun.corba.se.impl.orbutil.DenseIntMapImpl ;
import com.sun.corba.se.spi.copyobject.ObjectCopierFactory ;
import com.sun.corba.se.spi.copyobject.CopierManager ;
import com.sun.corba.se.spi.copyobject.ObjectCopierFactory ;
public class CopierManagerImpl implements CopierManager
{
private int defaultId ;
private DenseIntMapImpl map ;
private ORB orb ;
public CopierManagerImpl( ORB orb )
{
defaultId = 0 ;
map = new DenseIntMapImpl() ;
this.orb = orb ;
}
public void setDefaultId( int id )
{
defaultId = id ;
}
public int getDefaultId()
{
return defaultId ;
}
public ObjectCopierFactory getObjectCopierFactory( int id )
{
return (ObjectCopierFactory)(map.get( id )) ;
}
public ObjectCopierFactory getDefaultObjectCopierFactory()
{
return (ObjectCopierFactory)(map.get( defaultId )) ;
}
public void registerObjectCopierFactory( ObjectCopierFactory factory, int id )
{
map.set( id, factory ) ;
}
}

View file

@ -1,55 +0,0 @@
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.copyobject ;
import com.sun.corba.se.spi.copyobject.ObjectCopier ;
import com.sun.corba.se.spi.copyobject.ReflectiveCopyException ;
/** Trys a first ObjectCopier. If the first throws a ReflectiveCopyException,
* falls back and tries a second ObjectCopier.
*/
public class FallbackObjectCopierImpl implements ObjectCopier
{
private ObjectCopier first ;
private ObjectCopier second ;
public FallbackObjectCopierImpl( ObjectCopier first,
ObjectCopier second )
{
this.first = first ;
this.second = second ;
}
public Object copy( Object src ) throws ReflectiveCopyException
{
try {
return first.copy( src ) ;
} catch (ReflectiveCopyException rce ) {
// XXX log this fallback at a low level
return second.copy( src ) ;
}
}
}

View file

@ -1,78 +0,0 @@
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.copyobject ;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.Serializable;
import java.rmi.Remote;
import java.rmi.MarshalException;
import java.io.InputStream ;
import java.io.OutputStream ;
import java.io.ByteArrayInputStream ;
import java.io.ByteArrayOutputStream ;
import java.io.ObjectInputStream ;
import java.io.ObjectOutputStream ;
import org.omg.CORBA.ORB ;
import com.sun.corba.se.spi.copyobject.ObjectCopier ;
import com.sun.corba.se.impl.util.Utility;
public class JavaStreamObjectCopierImpl implements ObjectCopier {
public JavaStreamObjectCopierImpl( ORB orb )
{
this.orb = orb ;
}
public Object copy(Object obj) {
if (obj instanceof Remote) {
// Yes, so make sure it is connected and converted
// to a stub (if needed)...
return Utility.autoConnect(obj,orb,true);
}
try {
ByteArrayOutputStream os = new ByteArrayOutputStream( 10000 ) ;
ObjectOutputStream oos = new ObjectOutputStream( os ) ;
oos.writeObject( obj ) ;
byte[] arr = os.toByteArray() ;
InputStream is = new ByteArrayInputStream( arr ) ;
ObjectInputStream ois = new ObjectInputStream( is ) ;
return ois.readObject();
} catch (Exception exc) {
System.out.println( "Failed with exception:" + exc ) ;
return null ;
}
}
private ORB orb;
}

View file

@ -1,63 +0,0 @@
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.copyobject ;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.Serializable;
import java.rmi.Remote;
import java.rmi.MarshalException;
import org.omg.CORBA_2_3.portable.InputStream;
import org.omg.CORBA_2_3.portable.OutputStream;
import org.omg.CORBA.ORB ;
import com.sun.corba.se.spi.copyobject.ObjectCopier ;
import com.sun.corba.se.impl.util.Utility;
public class ORBStreamObjectCopierImpl implements ObjectCopier {
public ORBStreamObjectCopierImpl( ORB orb )
{
this.orb = orb ;
}
public Object copy(Object obj) {
if (obj instanceof Remote) {
// Yes, so make sure it is connected and converted
// to a stub (if needed)...
return Utility.autoConnect(obj,orb,true);
}
OutputStream out = (OutputStream)orb.create_output_stream();
out.write_value((Serializable)obj);
InputStream in = (InputStream)out.create_input_stream();
return in.read_value();
}
private ORB orb;
}

View file

@ -1,36 +0,0 @@
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.copyobject ;
import com.sun.corba.se.spi.copyobject.ObjectCopier ;
public class ReferenceObjectCopierImpl implements ObjectCopier
{
public Object copy( Object obj )
{
return obj ;
}
}

View file

@ -1,78 +0,0 @@
/*
* Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package com.sun.corba.se.impl.corba;
abstract public class AnyImplHelper
{
private static String _id = "IDL:omg.org/CORBA/Any:1.0";
public static void insert (org.omg.CORBA.Any a, org.omg.CORBA.Any that)
{
org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
a.type (type ());
write (out, that);
a.read_value (out.create_input_stream (), type ());
}
public static org.omg.CORBA.Any extract (org.omg.CORBA.Any a)
{
return read (a.create_input_stream ());
}
private static org.omg.CORBA.TypeCode __typeCode = null;
synchronized public static org.omg.CORBA.TypeCode type ()
{
if (__typeCode == null)
{
__typeCode = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_any);
}
return __typeCode;
}
public static String id ()
{
return _id;
}
public static org.omg.CORBA.Any read (org.omg.CORBA.portable.InputStream istream)
{
return istream.read_any ();
}
public static void write (org.omg.CORBA.portable.OutputStream ostream, org.omg.CORBA.Any value)
{
ostream.write_any (value);
}
}

View file

@ -1,92 +0,0 @@
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package com.sun.corba.se.impl.corba;
import com.sun.corba.se.spi.orb.ORB ;
///////////////////////////////////////////////////////////////////////////
// helper class for deferred invocations
/*
* The AsynchInvoke class allows for the support of asynchronous
* invocations. Instances of these are created with a request object,
* and when run, perform an invocation. The instance is also
* responsible for waking up a client that might be waiting on the
* 'get_response' method.
*/
public class AsynchInvoke implements Runnable {
private RequestImpl _req;
private ORB _orb;
private boolean _notifyORB;
public AsynchInvoke (ORB o, RequestImpl reqToInvokeOn, boolean n)
{
_orb = o;
_req = reqToInvokeOn;
_notifyORB = n;
};
/*
* The run operation calls the invocation on the request object,
* updates the RequestImpl state to indicate that the asynchronous
* invocation is complete, and wakes up any client that might be
* waiting on a 'get_response' call.
*
*/
public void run()
{
// do the actual invocation
_req.doInvocation();
// for the asynchronous case, note that the response has been
// received.
synchronized (_req)
{
// update local boolean indicator
_req.gotResponse = true;
// notify any client waiting on a 'get_response'
_req.notify();
}
if (_notifyORB == true) {
_orb.notifyORB() ;
}
}
};
///////////////////////////////////////////////////////////////////////////

View file

@ -1,43 +0,0 @@
/*
* Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package com.sun.corba.se.impl.corba;
//
// Bare implementation of CORBA Object.
//
public class CORBAObjectImpl extends org.omg.CORBA_2_3.portable.ObjectImpl {
public String[] _ids() {
String[] typeids = new String[1];
typeids[0] = "IDL:omg.org/CORBA/Object:1.0";
return typeids;
}
}

View file

@ -1,98 +0,0 @@
/*
* Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package com.sun.corba.se.impl.corba;
import org.omg.CORBA.Any;
import org.omg.CORBA.Context;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.NVList;
import com.sun.corba.se.spi.logging.CORBALogDomains ;
import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
public final class ContextImpl extends Context {
private org.omg.CORBA.ORB _orb;
private ORBUtilSystemException wrapper ;
public ContextImpl(org.omg.CORBA.ORB orb)
{
_orb = orb;
wrapper = ORBUtilSystemException.get(
(com.sun.corba.se.spi.orb.ORB)orb,
CORBALogDomains.RPC_PRESENTATION ) ;
}
public ContextImpl(Context parent)
{
throw wrapper.contextNotImplemented() ;
}
public String context_name()
{
throw wrapper.contextNotImplemented() ;
}
public Context parent()
{
throw wrapper.contextNotImplemented() ;
}
public Context create_child(String name)
{
throw wrapper.contextNotImplemented() ;
}
public void set_one_value(String propName, Any propValue)
{
throw wrapper.contextNotImplemented() ;
}
public void set_values(NVList values)
{
throw wrapper.contextNotImplemented() ;
}
public void delete_values(String propName)
{
throw wrapper.contextNotImplemented() ;
}
public NVList get_values(String startScope,
int opFlags,
String propName)
{
throw wrapper.contextNotImplemented() ;
}
};

View file

@ -1,84 +0,0 @@
/*
* Copyright (c) 1996, 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package com.sun.corba.se.impl.corba;
import java.util.Vector;
import org.omg.CORBA.ContextList;
import org.omg.CORBA.Bounds;
import org.omg.CORBA.ORB;
public class ContextListImpl extends ContextList
{
private final int INITIAL_CAPACITY = 2;
private final int CAPACITY_INCREMENT = 2;
private org.omg.CORBA.ORB _orb;
private Vector _contexts;
public ContextListImpl(org.omg.CORBA.ORB orb)
{
// Note: This orb could be an instanceof ORBSingleton or ORB
_orb = orb;
_contexts = new Vector(INITIAL_CAPACITY, CAPACITY_INCREMENT);
}
public int count()
{
return _contexts.size();
}
public void add(String ctxt)
{
_contexts.addElement(ctxt);
}
public String item(int index)
throws Bounds
{
try {
return (String) _contexts.elementAt(index);
} catch (ArrayIndexOutOfBoundsException e) {
throw new Bounds();
}
}
public void remove(int index)
throws Bounds
{
try {
_contexts.removeElementAt(index);
} catch (ArrayIndexOutOfBoundsException e) {
throw new Bounds();
}
}
}

View file

@ -1,61 +0,0 @@
/*
* Copyright (c) 1996, 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package com.sun.corba.se.impl.corba;
import org.omg.CORBA.Environment;
import org.omg.CORBA.UserException;
import org.omg.CORBA.ORB;
public class EnvironmentImpl extends Environment {
private Exception _exc;
public EnvironmentImpl()
{
}
public Exception exception()
{
return _exc;
}
public void exception(Exception exc)
{
_exc = exc;
}
public void clear()
{
_exc = null;
}
}

View file

@ -1,83 +0,0 @@
/*
* Copyright (c) 1996, 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package com.sun.corba.se.impl.corba;
import java.util.Vector;
import org.omg.CORBA.Bounds;
import org.omg.CORBA.ExceptionList;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.ORB;
public class ExceptionListImpl extends ExceptionList {
private final int INITIAL_CAPACITY = 2;
private final int CAPACITY_INCREMENT = 2;
private Vector _exceptions;
public ExceptionListImpl() {
_exceptions = new Vector(INITIAL_CAPACITY, CAPACITY_INCREMENT);
}
public int count()
{
return _exceptions.size();
}
public void add(TypeCode tc)
{
_exceptions.addElement(tc);
}
public TypeCode item(int index)
throws Bounds
{
try {
return (TypeCode) _exceptions.elementAt(index);
} catch (ArrayIndexOutOfBoundsException e) {
throw new Bounds();
}
}
public void remove(int index)
throws Bounds
{
try {
_exceptions.removeElementAt(index);
} catch (ArrayIndexOutOfBoundsException e) {
throw new Bounds();
}
}
}

View file

@ -1,113 +0,0 @@
/*
* Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package com.sun.corba.se.impl.corba;
import java.util.Vector;
import org.omg.CORBA.Any;
import org.omg.CORBA.Bounds;
import org.omg.CORBA.NVList;
import org.omg.CORBA.NamedValue;
import com.sun.corba.se.spi.orb.ORB ;
public class NVListImpl extends NVList
{
private final int INITIAL_CAPACITY = 4;
private final int CAPACITY_INCREMENT = 2;
private Vector _namedValues;
private ORB orb;
public NVListImpl(ORB orb)
{
// Note: This orb could be an instanceof ORBSingleton or ORB
this.orb = orb;
_namedValues = new Vector(INITIAL_CAPACITY, CAPACITY_INCREMENT);
}
public NVListImpl(ORB orb, int size)
{
this.orb = orb;
// Note: the size arg is only a hint of the size of the NVList.
_namedValues = new Vector(size);
}
public int count()
{
return _namedValues.size();
}
public NamedValue add(int flags)
{
NamedValue tmpVal = new NamedValueImpl(orb, "", new AnyImpl(orb), flags);
_namedValues.addElement(tmpVal);
return tmpVal;
}
public NamedValue add_item(String itemName, int flags)
{
NamedValue tmpVal = new NamedValueImpl(orb, itemName, new AnyImpl(orb),
flags);
_namedValues.addElement(tmpVal);
return tmpVal;
}
public NamedValue add_value(String itemName, Any val, int flags)
{
NamedValue tmpVal = new NamedValueImpl(orb, itemName, val, flags);
_namedValues.addElement(tmpVal);
return tmpVal;
}
public NamedValue item(int index)
throws Bounds
{
try {
return (NamedValue) _namedValues.elementAt(index);
} catch (ArrayIndexOutOfBoundsException e) {
throw new Bounds();
}
}
public void remove(int index)
throws Bounds
{
try {
_namedValues.removeElementAt(index);
} catch (ArrayIndexOutOfBoundsException e) {
throw new Bounds();
}
}
}

View file

@ -1,79 +0,0 @@
/*
* Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package com.sun.corba.se.impl.corba;
import org.omg.CORBA.NamedValue;
import org.omg.CORBA.Any;
import com.sun.corba.se.spi.orb.ORB ;
public class NamedValueImpl extends NamedValue
{
private String _name;
private Any _value;
private int _flags;
private ORB _orb;
public NamedValueImpl(ORB orb)
{
// Note: This orb could be an instanceof ORBSingleton or ORB
_orb = orb;
_value = new AnyImpl(_orb);
}
public NamedValueImpl(ORB orb,
String name,
Any value,
int flags)
{
// Note: This orb could be an instanceof ORBSingleton or ORB
_orb = orb;
_name = name;
_value = value;
_flags = flags;
}
public String name()
{
return _name;
}
public Any value()
{
return _value;
}
public int flags()
{
return _flags;
}
}

View file

@ -1,48 +0,0 @@
/*
* Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package com.sun.corba.se.impl.corba;
public class PrincipalImpl extends org.omg.CORBA.Principal
{
private byte[] value;
public void name(byte[] value)
{
this.value = value;
}
public byte[] name()
{
return value;
}
}

View file

@ -1,374 +0,0 @@
/*
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package com.sun.corba.se.impl.corba;
import org.omg.CORBA.Any;
import org.omg.CORBA.ARG_IN;
import org.omg.CORBA.ARG_OUT;
import org.omg.CORBA.ARG_INOUT;
import org.omg.CORBA.Context;
import org.omg.CORBA.ContextList;
import org.omg.CORBA.Environment;
import org.omg.CORBA.ExceptionList;
import org.omg.CORBA.NVList;
import org.omg.CORBA.NamedValue;
import org.omg.CORBA.Request;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.UnknownUserException;
import org.omg.CORBA.Bounds;
import org.omg.CORBA.UNKNOWN;
import org.omg.CORBA.INTERNAL;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.WrongTransaction;
import org.omg.CORBA.portable.ApplicationException ;
import org.omg.CORBA.portable.RemarshalException ;
import org.omg.CORBA.portable.InputStream ;
import org.omg.CORBA.portable.OutputStream ;
import com.sun.corba.se.spi.orb.ORB;
import com.sun.corba.se.spi.presentation.rmi.StubAdapter;
import com.sun.corba.se.spi.logging.CORBALogDomains;
import com.sun.corba.se.impl.logging.ORBUtilSystemException;
import com.sun.corba.se.impl.corba.AsynchInvoke;
public class RequestImpl
extends Request
{
///////////////////////////////////////////////////////////////////////////
// data members
protected org.omg.CORBA.Object _target;
protected String _opName;
protected NVList _arguments;
protected ExceptionList _exceptions;
private NamedValue _result;
protected Environment _env;
private Context _ctx;
private ContextList _ctxList;
protected ORB _orb;
private ORBUtilSystemException _wrapper;
// invocation-specific stuff
protected boolean _isOneWay = false;
private int[] _paramCodes;
private long[] _paramLongs;
private java.lang.Object[] _paramObjects;
// support for deferred invocations.
// protected instead of private since it needs to be set by the
// thread object doing the asynchronous invocation.
protected boolean gotResponse = false;
///////////////////////////////////////////////////////////////////////////
// constructor
// REVISIT - used to be protected. Now public so it can be
// accessed from xgiop.
public RequestImpl (ORB orb,
org.omg.CORBA.Object targetObject,
Context ctx,
String operationName,
NVList argumentList,
NamedValue resultContainer,
ExceptionList exceptionList,
ContextList ctxList)
{
// initialize the orb
_orb = orb;
_wrapper = ORBUtilSystemException.get( orb,
CORBALogDomains.OA_INVOCATION ) ;
// initialize target, context and operation name
_target = targetObject;
_ctx = ctx;
_opName = operationName;
// initialize argument list if not passed in
if (argumentList == null)
_arguments = new NVListImpl(_orb);
else
_arguments = argumentList;
// set result container.
_result = resultContainer;
// initialize exception list if not passed in
if (exceptionList == null)
_exceptions = new ExceptionListImpl();
else
_exceptions = exceptionList;
// initialize context list if not passed in
if (ctxList == null)
_ctxList = new ContextListImpl(_orb);
else
_ctxList = ctxList;
// initialize environment
_env = new EnvironmentImpl();
}
public org.omg.CORBA.Object target()
{
return _target;
}
public String operation()
{
return _opName;
}
public NVList arguments()
{
return _arguments;
}
public NamedValue result()
{
return _result;
}
public Environment env()
{
return _env;
}
public ExceptionList exceptions()
{
return _exceptions;
}
public ContextList contexts()
{
return _ctxList;
}
public synchronized Context ctx()
{
if (_ctx == null)
_ctx = new ContextImpl(_orb);
return _ctx;
}
public synchronized void ctx(Context newCtx)
{
_ctx = newCtx;
}
public synchronized Any add_in_arg()
{
return _arguments.add(org.omg.CORBA.ARG_IN.value).value();
}
public synchronized Any add_named_in_arg(String name)
{
return _arguments.add_item(name, org.omg.CORBA.ARG_IN.value).value();
}
public synchronized Any add_inout_arg()
{
return _arguments.add(org.omg.CORBA.ARG_INOUT.value).value();
}
public synchronized Any add_named_inout_arg(String name)
{
return _arguments.add_item(name, org.omg.CORBA.ARG_INOUT.value).value();
}
public synchronized Any add_out_arg()
{
return _arguments.add(org.omg.CORBA.ARG_OUT.value).value();
}
public synchronized Any add_named_out_arg(String name)
{
return _arguments.add_item(name, org.omg.CORBA.ARG_OUT.value).value();
}
public synchronized void set_return_type(TypeCode tc)
{
if (_result == null)
_result = new NamedValueImpl(_orb);
_result.value().type(tc);
}
public synchronized Any return_value()
{
if (_result == null)
_result = new NamedValueImpl(_orb);
return _result.value();
}
public synchronized void add_exception(TypeCode exceptionType)
{
_exceptions.add(exceptionType);
}
public synchronized void invoke()
{
doInvocation();
}
public synchronized void send_oneway()
{
_isOneWay = true;
doInvocation();
}
public synchronized void send_deferred()
{
AsynchInvoke invokeObject = new AsynchInvoke(_orb, this, false);
new Thread(null, invokeObject, "Async-Request-Invoker-Thread", 0, false).start();
}
public synchronized boolean poll_response()
{
// this method has to be synchronized even though it seems
// "readonly" since the thread object doing the asynchronous
// invocation can potentially update this variable in parallel.
// updates are currently simply synchronized againt the request
// object.
return gotResponse;
}
public synchronized void get_response()
throws org.omg.CORBA.WrongTransaction
{
while (gotResponse == false) {
// release the lock. wait to be notified by the thread that is
// doing the asynchronous invocation.
try {
wait();
}
catch (InterruptedException e) {}
}
}
///////////////////////////////////////////////////////////////////////////
// private helper methods
/*
* The doInvocation operation is where the real mechanics of
* performing the request invocation is done.
*/
protected void doInvocation()
{
org.omg.CORBA.portable.Delegate delegate = StubAdapter.getDelegate(
_target ) ;
// Initiate Client Portable Interceptors. Inform the PIHandler that
// this is a DII request so that it knows to ignore the second
// inevitable call to initiateClientPIRequest in createRequest.
// Also, save the RequestImpl object for later use.
_orb.getPIHandler().initiateClientPIRequest( true );
_orb.getPIHandler().setClientPIInfo( this );
InputStream $in = null;
try {
OutputStream $out = delegate.request(null, _opName, !_isOneWay);
// Marshal args
try {
for (int i=0; i<_arguments.count() ; i++) {
NamedValue nv = _arguments.item(i);
switch (nv.flags()) {
case ARG_IN.value:
nv.value().write_value($out);
break;
case ARG_OUT.value:
break;
case ARG_INOUT.value:
nv.value().write_value($out);
break;
}
}
} catch ( org.omg.CORBA.Bounds ex ) {
throw _wrapper.boundsErrorInDiiRequest( ex ) ;
}
$in = delegate.invoke(null, $out);
} catch (ApplicationException e) {
// REVISIT - minor code.
// This is already handled in subcontract.
// REVISIT - uncomment.
//throw new INTERNAL();
} catch (RemarshalException e) {
doInvocation();
} catch( SystemException ex ) {
_env.exception(ex);
// NOTE: The exception should not be thrown.
// However, JDK 1.4 and earlier threw the exception,
// so we keep the behavior to be compatible.
throw ex;
} finally {
delegate.releaseReply(null, $in);
}
}
// REVISIT - make protected after development - so xgiop can get it.
public void unmarshalReply(InputStream is)
{
// First unmarshal the return value if it is not void
if ( _result != null ) {
Any returnAny = _result.value();
TypeCode returnType = returnAny.type();
if ( returnType.kind().value() != TCKind._tk_void )
returnAny.read_value(is, returnType);
}
// Now unmarshal the out/inout args
try {
for ( int i=0; i<_arguments.count() ; i++) {
NamedValue nv = _arguments.item(i);
switch( nv.flags() ) {
case ARG_IN.value:
break;
case ARG_OUT.value:
case ARG_INOUT.value:
Any any = nv.value();
any.read_value(is, any.type());
break;
}
}
}
catch ( org.omg.CORBA.Bounds ex ) {
// Cannot happen since we only iterate till _arguments.count()
}
}
}

View file

@ -1,257 +0,0 @@
/*
* Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package com.sun.corba.se.impl.corba;
import org.omg.CORBA.Any;
import org.omg.CORBA.Context;
import org.omg.CORBA.NamedValue;
import org.omg.CORBA.NVList;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.ServerRequest;
import org.omg.CORBA.Bounds;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.CompletionStatus;
import com.sun.corba.se.spi.orb.ORB ;
import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
import com.sun.corba.se.spi.logging.CORBALogDomains ;
import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
public class ServerRequestImpl extends ServerRequest {
///////////////////////////////////////////////////////////////////////////
// data members
private ORB _orb = null;
private ORBUtilSystemException _wrapper = null;
private String _opName = null;
private NVList _arguments = null;
private Context _ctx = null;
private InputStream _ins = null;
// booleans to check for various operation invocation restrictions
private boolean _paramsCalled = false;
private boolean _resultSet = false;
private boolean _exceptionSet = false;
private Any _resultAny = null;
private Any _exception = null;
public ServerRequestImpl (CorbaMessageMediator req, ORB orb) {
_opName = req.getOperationName();
_ins = (InputStream)req.getInputObject();
_ctx = null; // if we support contexts, this would
// presumably also be available on
// the server invocation
_orb = orb;
_wrapper = ORBUtilSystemException.get( orb,
CORBALogDomains.OA_INVOCATION ) ;
}
public String operation() {
return _opName;
}
public void arguments(NVList args)
{
if (_paramsCalled)
throw _wrapper.argumentsCalledMultiple() ;
if (_exceptionSet)
throw _wrapper.argumentsCalledAfterException() ;
if (args == null )
throw _wrapper.argumentsCalledNullArgs() ;
_paramsCalled = true;
NamedValue arg = null;
for (int i=0; i < args.count() ; i++) {
try {
arg = args.item(i);
} catch (Bounds e) {
throw _wrapper.boundsCannotOccur(e) ;
}
try {
if ((arg.flags() == org.omg.CORBA.ARG_IN.value) ||
(arg.flags() == org.omg.CORBA.ARG_INOUT.value)) {
// unmarshal the value into the Any
arg.value().read_value(_ins, arg.value().type());
}
} catch ( Exception ex ) {
throw _wrapper.badArgumentsNvlist( ex ) ;
}
}
// hang on to the NVList for marshaling the result
_arguments = args;
_orb.getPIHandler().setServerPIInfo( _arguments );
_orb.getPIHandler().invokeServerPIIntermediatePoint();
}
public void set_result(Any res) {
// check for invocation restrictions
if (!_paramsCalled)
throw _wrapper.argumentsNotCalled() ;
if (_resultSet)
throw _wrapper.setResultCalledMultiple() ;
if (_exceptionSet)
throw _wrapper.setResultAfterException() ;
if ( res == null )
throw _wrapper.setResultCalledNullArgs() ;
_resultAny = res;
_resultSet = true;
// Notify portable interceptors of the result so that
// ServerRequestInfo.result() functions as desired.
_orb.getPIHandler().setServerPIInfo( _resultAny );
// actual marshaling of the reply msg header and params takes place
// after the DSI returns control to the ORB.
}
public void set_exception(Any exc)
{
// except can be called by the DIR at any time (CORBA 2.2 section 6.3).
if ( exc == null )
throw _wrapper.setExceptionCalledNullArgs() ;
// Ensure that the Any contains a SystemException or a
// UserException. If the UserException is not a declared exception,
// the client will get an UNKNOWN exception.
TCKind kind = exc.type().kind();
if ( kind != TCKind.tk_except )
throw _wrapper.setExceptionCalledBadType() ;
_exception = exc;
// Inform Portable interceptors of the exception that was set
// so sending_exception can return the right value.
_orb.getPIHandler().setServerPIExceptionInfo( _exception );
// The user can only call arguments once and not at all after
// set_exception. (internal flags ensure this). However, the user
// can call set_exception multiple times. Therefore, we only
// invoke receive_request the first time set_exception is
// called (if they haven't already called arguments).
if( !_exceptionSet && !_paramsCalled ) {
// We need to invoke intermediate points here.
_orb.getPIHandler().invokeServerPIIntermediatePoint();
}
_exceptionSet = true;
// actual marshaling of the reply msg header and exception takes place
// after the DSI returns control to the ORB.
}
/** This is called from the ORB after the DynamicImplementation.invoke
* returns. Here we set the result if result() has not already been called.
* @return the exception if there is one (then ORB will not call
* marshalReplyParams()) otherwise return null.
*/
public Any checkResultCalled()
{
// Two things to be checked (CORBA 2.2 spec, section 6.3):
// 1. Unless it calls set_exception(), the DIR must call arguments()
// exactly once, even if the operation signature contains
// no parameters.
// 2. Unless set_exception() is called, if the invoked operation has a
// non-void result type, set_result() must be called exactly once
// before the DIR returns.
if ( _paramsCalled && _resultSet ) // normal invocation return
return null;
else if ( _paramsCalled && !_resultSet && !_exceptionSet ) {
try {
// Neither a result nor an exception has been set.
// Assume that the return type is void. If this is not so,
// the client will throw a MARSHAL exception while
// unmarshaling the return value.
TypeCode result_tc = _orb.get_primitive_tc(
org.omg.CORBA.TCKind.tk_void);
_resultAny = _orb.create_any();
_resultAny.type(result_tc);
_resultSet = true;
return null;
} catch ( Exception ex ) {
throw _wrapper.dsiResultException(
CompletionStatus.COMPLETED_MAYBE, ex ) ;
}
} else if ( _exceptionSet )
return _exception;
else {
throw _wrapper.dsimethodNotcalled(
CompletionStatus.COMPLETED_MAYBE ) ;
}
}
/** This is called from the ORB after the DynamicImplementation.invoke
* returns. Here we marshal the return value and inout/out params.
*/
public void marshalReplyParams(OutputStream os)
{
// marshal the operation return value
_resultAny.write_value(os);
// marshal the inouts/outs
NamedValue arg = null;
for (int i=0; i < _arguments.count() ; i++) {
try {
arg = _arguments.item(i);
} catch (Bounds e) {}
if ((arg.flags() == org.omg.CORBA.ARG_OUT.value) ||
(arg.flags() == org.omg.CORBA.ARG_INOUT.value)) {
arg.value().write_value(os);
}
}
}
public Context ctx()
{
if ( !_paramsCalled || _resultSet || _exceptionSet )
throw _wrapper.contextCalledOutOfOrder() ;
throw _wrapper.contextNotImplemented() ;
}
}

View file

@ -1,329 +0,0 @@
/*
* Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
*/
package com.sun.corba.se.impl.corba;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.UserException;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.UNKNOWN;
import org.omg.CORBA.INTERNAL;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.Any;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.Principal;
import org.omg.CORBA_2_3.portable.InputStream;
import org.omg.CORBA_2_3.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
import org.omg.CORBA.TypeCodePackage.BadKind;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import com.sun.corba.se.impl.encoding.CDRInputStream;
import com.sun.corba.se.impl.encoding.CDROutputStream;
import java.io.Serializable;
import java.math.BigDecimal;
import com.sun.corba.se.spi.logging.CORBALogDomains ;
import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
/**
* Static functions for TypeCode interpretation.
*/
public final class TCUtility {
static void marshalIn(org.omg.CORBA.portable.OutputStream s, TypeCode typeCode, long l, Object o) {
switch (typeCode.kind().value()) {
case TCKind._tk_null:
case TCKind._tk_void:
case TCKind._tk_native:
// nothing to write
break;
case TCKind._tk_short:
s.write_short((short)(l & 0xFFFFL));
break;
case TCKind._tk_ushort:
s.write_ushort((short)(l & 0xFFFFL));
break;
case TCKind._tk_enum:
case TCKind._tk_long:
s.write_long((int)(l & 0xFFFFFFFFL));
break;
case TCKind._tk_ulong:
s.write_ulong((int)(l & 0xFFFFFFFFL));
break;
case TCKind._tk_float:
s.write_float(Float.intBitsToFloat((int)(l & 0xFFFFFFFFL)));
break;
case TCKind._tk_double:
s.write_double(Double.longBitsToDouble(l));
break;
case TCKind._tk_boolean:
if ( l == 0 )
s.write_boolean(false);
else
s.write_boolean(true);
break;
case TCKind._tk_char:
s.write_char((char)(l & 0xFFFFL));
break;
case TCKind._tk_octet:
s.write_octet((byte)(l & 0xFFL));
break;
case TCKind._tk_any:
s.write_any((Any)o);
break;
case TCKind._tk_TypeCode:
s.write_TypeCode((TypeCode)o);
break;
case TCKind._tk_Principal:
s.write_Principal((Principal)o);
break;
case TCKind._tk_objref:
s.write_Object((org.omg.CORBA.Object)o);
break;
case TCKind._tk_longlong:
s.write_longlong(l);
break;
case TCKind._tk_ulonglong:
s.write_ulonglong(l);
break;
case TCKind._tk_wchar:
s.write_wchar((char)(l & 0xFFFFL));
break;
case TCKind._tk_string:
s.write_string((String)o);
break;
case TCKind._tk_wstring:
s.write_wstring((String)o);
break;
case TCKind._tk_value:
case TCKind._tk_value_box:
((org.omg.CORBA_2_3.portable.OutputStream)s).write_value((Serializable)o);
break;
case TCKind._tk_fixed:
// _REVISIT_ As soon as the java-rtf adds digits and scale parameters to
// OutputStream, this check will be unnecessary
if (s instanceof CDROutputStream) {
try {
((CDROutputStream)s).write_fixed((BigDecimal)o,
typeCode.fixed_digits(),
typeCode.fixed_scale());
} catch (BadKind badKind) { // impossible
}
} else {
s.write_fixed((BigDecimal)o);
}
break;
case TCKind._tk_struct:
case TCKind._tk_union:
case TCKind._tk_sequence:
case TCKind._tk_array:
case TCKind._tk_alias:
case TCKind._tk_except:
((Streamable)o)._write(s);
break;
case TCKind._tk_abstract_interface:
((org.omg.CORBA_2_3.portable.OutputStream)s).write_abstract_interface(o);
break;
case TCKind._tk_longdouble:
// Unspecified for Java
default:
ORBUtilSystemException wrapper = ORBUtilSystemException.get(
(com.sun.corba.se.spi.orb.ORB)s.orb(),
CORBALogDomains.RPC_PRESENTATION ) ;
throw wrapper.typecodeNotSupported() ;
}
}
static void unmarshalIn(org.omg.CORBA.portable.InputStream s, TypeCode typeCode, long[] la, Object[] oa)
{
int type = typeCode.kind().value();
long l=0;
Object o=oa[0];
switch (type) {
case TCKind._tk_null:
case TCKind._tk_void:
case TCKind._tk_native:
// Nothing to read
break;
case TCKind._tk_short:
l = s.read_short() & 0xFFFFL;
break;
case TCKind._tk_ushort:
l = s.read_ushort() & 0xFFFFL;
break;
case TCKind._tk_enum:
case TCKind._tk_long:
l = s.read_long() & 0xFFFFFFFFL;
break;
case TCKind._tk_ulong:
l = s.read_ulong() & 0xFFFFFFFFL;
break;
case TCKind._tk_float:
l = Float.floatToIntBits(s.read_float()) & 0xFFFFFFFFL;
break;
case TCKind._tk_double:
l = Double.doubleToLongBits(s.read_double());
break;
case TCKind._tk_char:
l = s.read_char() & 0xFFFFL;
break;
case TCKind._tk_octet:
l = s.read_octet() & 0xFFL;
break;
case TCKind._tk_boolean:
if ( s.read_boolean() )
l = 1;
else
l = 0;
break;
case TCKind._tk_any:
o = s.read_any();
break;
case TCKind._tk_TypeCode:
o = s.read_TypeCode();
break;
case TCKind._tk_Principal:
o = s.read_Principal();
break;
case TCKind._tk_objref:
if (o instanceof Streamable)
((Streamable)o)._read(s);
else
o = s.read_Object();
break;
case TCKind._tk_longlong:
l = s.read_longlong();
break;
case TCKind._tk_ulonglong:
l = s.read_ulonglong();
break;
case TCKind._tk_wchar:
l = s.read_wchar() & 0xFFFFL;
break;
case TCKind._tk_string:
o = s.read_string();
break;
case TCKind._tk_wstring:
o = s.read_wstring();
break;
case TCKind._tk_value:
case TCKind._tk_value_box:
o = ((org.omg.CORBA_2_3.portable.InputStream)s).read_value ();
break;
case TCKind._tk_fixed:
try {
// _REVISIT_ As soon as the java-rtf adds digits and scale parameters to
// InputStream, this check will be unnecessary
if (s instanceof CDRInputStream) {
o = ((CDRInputStream)s).read_fixed(typeCode.fixed_digits(),
typeCode.fixed_scale());
} else {
BigDecimal bigDecimal = s.read_fixed();
o = bigDecimal.movePointLeft((int)typeCode.fixed_scale());
}
} catch (BadKind badKind) { // impossible
}
break;
case TCKind._tk_struct:
case TCKind._tk_union:
case TCKind._tk_sequence:
case TCKind._tk_array:
case TCKind._tk_alias:
case TCKind._tk_except:
((Streamable)o)._read(s);
break;
case TCKind._tk_abstract_interface:
o = ((org.omg.CORBA_2_3.portable.InputStream)s).read_abstract_interface();
break;
case TCKind._tk_longdouble:
// Unspecified for Java
default:
ORBUtilSystemException wrapper = ORBUtilSystemException.get(
(com.sun.corba.se.spi.orb.ORB)s.orb(),
CORBALogDomains.RPC_PRESENTATION ) ;
throw wrapper.typecodeNotSupported() ;
}
oa[0] = o;
la[0] = l;
}
}

View file

@ -1,36 +0,0 @@
/*
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.corba.se.impl.corba;
public interface TypeCodeFactory {
void setTypeCode(String id, TypeCodeImpl code);
TypeCodeImpl getTypeCode(String id);
void setTypeCodeForClass( Class c, TypeCodeImpl tcimpl ) ;
TypeCodeImpl getTypeCodeForClass( Class c ) ;
}

Some files were not shown because too many files have changed in this diff Show more