index int64 0 0 | repo_id stringlengths 9 205 | file_path stringlengths 31 246 | content stringlengths 1 12.2M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/ClientInterceptorProxy_impl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
import org.omg.PortableInterceptor.*;
final class ClientInterceptorProxy_impl extends org.omg.CORBA.LocalObject
implements ClientRequestInterceptor {
//
// From TestBase (no multiple inheritance)
//
public static void TEST(boolean expr) {
if (!expr)
throw new test.common.TestException();
}
private ClientRequestInterceptor interceptor_;
private int count_;
//
// IDL to Java Mapping
//
public String name() {
if (interceptor_ != null)
return interceptor_.name();
return "";
}
public void destroy() {
}
public void send_request(ClientRequestInfo ri) throws ForwardRequest {
TEST(count_ == 0);
if (interceptor_ != null)
interceptor_.send_request(ri);
count_++;
}
public void send_poll(ClientRequestInfo ri) {
TEST(false);
}
public void receive_reply(ClientRequestInfo ri) {
TEST(count_ == 1);
count_--;
if (interceptor_ != null)
interceptor_.receive_reply(ri);
}
public void receive_other(ClientRequestInfo ri) throws ForwardRequest {
TEST(count_ == 1);
count_--;
if (interceptor_ != null)
interceptor_.receive_other(ri);
}
public void receive_exception(ClientRequestInfo ri) throws ForwardRequest {
TEST(count_ == 1);
count_--;
if (interceptor_ != null)
interceptor_.receive_exception(ri);
}
void _OB_changeInterceptor(ClientRequestInterceptor ri) {
interceptor_ = ri;
}
}
| 5,700 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/ReplyContext.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:ReplyContext:1.0
//
/***/
final public class ReplyContext implements org.omg.CORBA.portable.IDLEntity
{
private static final String _ob_id = "IDL:ReplyContext:1.0";
public
ReplyContext()
{
}
public
ReplyContext(String data,
int val)
{
this.data = data;
this.val = val;
}
public String data;
public int val;
}
| 5,701 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/ReplyContextHolder.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:ReplyContext:1.0
//
final public class ReplyContextHolder implements org.omg.CORBA.portable.Streamable
{
public ReplyContext value;
public
ReplyContextHolder()
{
}
public
ReplyContextHolder(ReplyContext initial)
{
value = initial;
}
public void
_read(org.omg.CORBA.portable.InputStream in)
{
value = ReplyContextHelper.read(in);
}
public void
_write(org.omg.CORBA.portable.OutputStream out)
{
ReplyContextHelper.write(out, value);
}
public org.omg.CORBA.TypeCode
_type()
{
return ReplyContextHelper.type();
}
}
| 5,702 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/MyComponent.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:MyComponent:1.0
//
/***/
final public class MyComponent implements org.omg.CORBA.portable.IDLEntity
{
private static final String _ob_id = "IDL:MyComponent:1.0";
public
MyComponent()
{
}
public
MyComponent(int val)
{
this.val = val;
}
public int val;
}
| 5,703 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/foo.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:foo:1.0
//
/***/
final public class foo implements org.omg.CORBA.portable.IDLEntity
{
private static final String _ob_id = "IDL:foo:1.0";
public
foo()
{
}
public
foo(int l)
{
this.l = l;
}
public int l;
}
| 5,704 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/RequestContextHelper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:RequestContext:1.0
//
final public class RequestContextHelper
{
public static void
insert(org.omg.CORBA.Any any, RequestContext val)
{
org.omg.CORBA.portable.OutputStream out = any.create_output_stream();
write(out, val);
any.read_value(out.create_input_stream(), type());
}
public static RequestContext
extract(org.omg.CORBA.Any any)
{
if(any.type().equivalent(type()))
return read(any.create_input_stream());
else
throw new org.omg.CORBA.BAD_OPERATION();
}
private static org.omg.CORBA.TypeCode typeCode_;
public static org.omg.CORBA.TypeCode
type()
{
if(typeCode_ == null)
{
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
org.omg.CORBA.StructMember[] members = new org.omg.CORBA.StructMember[2];
members[0] = new org.omg.CORBA.StructMember();
members[0].name = "data";
members[0].type = orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_string);
members[1] = new org.omg.CORBA.StructMember();
members[1].name = "val";
members[1].type = orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_long);
typeCode_ = orb.create_struct_tc(id(), "RequestContext", members);
}
return typeCode_;
}
public static String
id()
{
return "IDL:RequestContext:1.0";
}
public static RequestContext
read(org.omg.CORBA.portable.InputStream in)
{
RequestContext _ob_v = new RequestContext();
_ob_v.data = in.read_string();
_ob_v.val = in.read_long();
return _ob_v;
}
public static void
write(org.omg.CORBA.portable.OutputStream out, RequestContext val)
{
out.write_string(val.data);
out.write_long(val.val);
}
}
| 5,705 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/TestInterface.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:TestInterface:1.0
//
/***/
public interface TestInterface extends TestInterfaceOperations,
org.omg.CORBA.Object,
org.omg.CORBA.portable.IDLEntity
{
}
| 5,706 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/ServerORBInitializer_impl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
import org.omg.PortableInterceptor.IORInterceptor;
import org.omg.PortableInterceptor.ORBInitInfo;
import org.omg.PortableInterceptor.ORBInitializer;
import org.omg.PortableInterceptor.PolicyFactory;
final public class ServerORBInitializer_impl extends org.omg.CORBA.LocalObject
implements ORBInitializer {
//
// From TestBase (no multiple inheritance)
//
public static void TEST(boolean expr) {
if (!expr)
throw new test.common.TestException();
}
static ServerProxyManager serverProxyManager;
//
// IDL to Java Mapping
//
public void pre_init(ORBInitInfo info) {
//
// Test: PICurrent::allocate_slot_id
//
int id = info.allocate_slot_id();
TEST(id >= 0);
//
// Test: register an IORInterceptor
//
IORInterceptor iorInterceptor = new MyIORInterceptor_impl(info);
try {
info.add_ior_interceptor(iorInterceptor);
} catch (org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName ex) {
throw new RuntimeException();
}
PolicyFactory pf = new MyServerPolicyFactory_impl();
info.register_policy_factory(MY_SERVER_POLICY_ID.value, pf);
serverProxyManager = new ServerProxyManager(info);
//
// TODO: Test resolve_initial_references
//
}
public void post_init(ORBInitInfo info) {
//
// TODO: Test resolve_initial_references
//
}
}
| 5,707 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/MY_COMPONENT_ID.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:MY_COMPONENT_ID:1.0
//
/***/
public interface MY_COMPONENT_ID
{
int value = (int)(100L);
}
| 5,708 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/MyClientPolicy_impl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
import org.omg.CORBA.*;
import org.omg.PortableInterceptor.*;
final class MyClientPolicy_impl extends org.omg.CORBA.LocalObject implements
MyClientPolicy {
private int value_;
MyClientPolicy_impl(int value) {
value_ = value;
}
//
// Standard IDL to Java Mapping
//
public int value() {
return value_;
}
public int policy_type() {
return MY_CLIENT_POLICY_ID.value;
}
public Policy copy() {
// TODO: Is this sufficient here?
return this;
}
public void destroy() {
}
}
| 5,709 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/REQUEST_CONTEXT_ID.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:REQUEST_CONTEXT_ID:1.0
//
/***/
public interface REQUEST_CONTEXT_ID
{
int value = (int)(100L);
}
| 5,710 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/MyServerPolicyHolder.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:MyServerPolicy:1.0
//
final public class MyServerPolicyHolder implements org.omg.CORBA.portable.Streamable
{
public MyServerPolicy value;
public
MyServerPolicyHolder()
{
}
public
MyServerPolicyHolder(MyServerPolicy initial)
{
value = initial;
}
public void
_read(org.omg.CORBA.portable.InputStream in)
{
value = MyServerPolicyHelper.read(in);
}
public void
_write(org.omg.CORBA.portable.OutputStream out)
{
MyServerPolicyHelper.write(out, value);
}
public org.omg.CORBA.TypeCode
_type()
{
return MyServerPolicyHelper.type();
}
}
| 5,711 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/REPLY_CONTEXT_1_ID.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:REPLY_CONTEXT_1_ID:1.0
//
/***/
public interface REPLY_CONTEXT_1_ID
{
int value = (int)(101L);
}
| 5,712 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/MyServerPolicyHelper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:MyServerPolicy:1.0
//
final public class MyServerPolicyHelper
{
public static void
insert(org.omg.CORBA.Any any, MyServerPolicy val)
{
any.insert_Object(val, type());
}
public static MyServerPolicy
extract(org.omg.CORBA.Any any)
{
if(any.type().equivalent(type()))
return narrow(any.extract_Object());
throw new org.omg.CORBA.BAD_OPERATION();
}
private static org.omg.CORBA.TypeCode typeCode_;
public static org.omg.CORBA.TypeCode
type()
{
if(typeCode_ == null)
{
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
typeCode_ = ((org.omg.CORBA_2_4.ORB)orb).create_local_interface_tc(id(), "MyServerPolicy");
}
return typeCode_;
}
public static String
id()
{
return "IDL:MyServerPolicy:1.0";
}
public static MyServerPolicy
read(org.omg.CORBA.portable.InputStream in)
{
throw new org.omg.CORBA.MARSHAL();
}
public static void
write(org.omg.CORBA.portable.OutputStream out, MyServerPolicy val)
{
throw new org.omg.CORBA.MARSHAL();
}
public static MyServerPolicy
narrow(org.omg.CORBA.Object val)
{
try
{
return (MyServerPolicy)val;
}
catch(ClassCastException ex)
{
}
throw new org.omg.CORBA.BAD_PARAM();
}
}
| 5,713 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/ClientProxyManager.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
import org.omg.PortableInterceptor.*;
final class ClientProxyManager {
private ClientInterceptorProxy_impl[] p_ = new ClientInterceptorProxy_impl[3];
ClientProxyManager(ORBInitInfo info) {
p_[0] = new ClientInterceptorProxy_impl();
p_[1] = new ClientInterceptorProxy_impl();
p_[2] = new ClientInterceptorProxy_impl();
//
// Register the client side interceptor
//
try {
info.add_client_request_interceptor(p_[0]);
info.add_client_request_interceptor(p_[1]);
info.add_client_request_interceptor(p_[2]);
} catch (org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName ex) {
throw new RuntimeException();
}
}
void setInterceptor(int which, ClientRequestInterceptor i) {
org.apache.yoko.orb.OB.Assert._OB_assert(which >= 0 && which < 3);
p_[which]._OB_changeInterceptor(i);
}
void clearInterceptors() {
setInterceptor(0, null);
setInterceptor(1, null);
setInterceptor(2, null);
}
}
| 5,714 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/TestInterfaceHolder.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:TestInterface:1.0
//
final public class TestInterfaceHolder implements org.omg.CORBA.portable.Streamable
{
public TestInterface value;
public
TestInterfaceHolder()
{
}
public
TestInterfaceHolder(TestInterface initial)
{
value = initial;
}
public void
_read(org.omg.CORBA.portable.InputStream in)
{
value = TestInterfaceHelper.read(in);
}
public void
_write(org.omg.CORBA.portable.OutputStream out)
{
TestInterfaceHelper.write(out, value);
}
public org.omg.CORBA.TypeCode
_type()
{
return TestInterfaceHelper.type();
}
}
| 5,715 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/REPLY_CONTEXT_3_ID.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:REPLY_CONTEXT_3_ID:1.0
//
/***/
public interface REPLY_CONTEXT_3_ID
{
int value = (int)(103L);
}
| 5,716 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/ClientORBInitializer_impl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
import org.omg.CORBA.*;
import org.omg.PortableInterceptor.*;
final public class ClientORBInitializer_impl extends org.omg.CORBA.LocalObject
implements ORBInitializer {
//
// From TestBase (no multiple inheritance)
//
public static void TEST(boolean expr) {
if (!expr)
throw new test.common.TestException();
}
static ClientProxyManager clientProxyManager;
private static boolean local_;
static void _OB_setLocal(boolean l) {
local_ = l;
}
//
// IDL to Java Mapping
//
public void pre_init(ORBInitInfo info) {
//
// Test: PICurrent::allocate_slot_id
//
if (!local_) {
int id = info.allocate_slot_id();
TEST(id >= 0);
}
//
// Test: Register a policy factory
//
PolicyFactory pf = new MyClientPolicyFactory_impl();
info.register_policy_factory(MY_CLIENT_POLICY_ID.value, pf);
System.out.print("Registering client request interceptors... ");
System.out.flush();
clientProxyManager = new ClientProxyManager(info);
System.out.println("Done!");
}
public void post_init(ORBInitInfo info) {
}
}
| 5,717 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/MyServerPolicy.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:MyServerPolicy:1.0
//
/***/
public interface MyServerPolicy extends MyServerPolicyOperations,
org.omg.CORBA.Policy
{
}
| 5,718 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/Server.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Properties;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Policy;
import org.omg.PortableInterceptor.ServerRequestInterceptor;
import org.omg.PortableServer.ID_ASSIGNMENT_POLICY_ID;
import org.omg.PortableServer.IMPLICIT_ACTIVATION_POLICY_ID;
import org.omg.PortableServer.IdAssignmentPolicyValue;
import org.omg.PortableServer.IdAssignmentPolicyValueHelper;
import org.omg.PortableServer.ImplicitActivationPolicyValue;
import org.omg.PortableServer.ImplicitActivationPolicyValueHelper;
import org.omg.PortableServer.LIFESPAN_POLICY_ID;
import org.omg.PortableServer.LifespanPolicyValue;
import org.omg.PortableServer.LifespanPolicyValueHelper;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;
import org.omg.PortableServer.POAManager;
import org.omg.PortableServer.REQUEST_PROCESSING_POLICY_ID;
import org.omg.PortableServer.RequestProcessingPolicyValue;
import org.omg.PortableServer.RequestProcessingPolicyValueHelper;
import org.omg.PortableServer.SERVANT_RETENTION_POLICY_ID;
import org.omg.PortableServer.ServantLocator;
import org.omg.PortableServer.ServantRetentionPolicyValue;
import org.omg.PortableServer.ServantRetentionPolicyValueHelper;
public final class Server extends test.common.TestBase {
private static String refFile = "TestInterface.ref";
private static TestLocator_impl locatorImpl;
static void ServerRegisterInterceptors(java.util.Properties props) {
props.put("org.omg.PortableInterceptor.ORBInitializerClass." + "test.pi.ServerORBInitializer_impl", "");
}
static void ServerRun(ORB orb, boolean nonBlocking, String[] args) throws Exception {
try (PrintWriter out = new PrintWriter(new FileWriter(refFile))) {
try {
Object c = Class.forName("test.pi.ServerORBInitializer_impl");
System.out.println("Got class " + c);
//
// Resolve Root POA
//
POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
System.out.println("Got root POA");
//
// Activate the POA manager
//
POAManager manager = poa.the_POAManager();
manager.activate();
System.out.println("Activated root poa manager");
//
// This will use ORB::create_policy to create all the POA policies
// and our custom policy
//
Any any = orb.create_any();
//
// Create policies for the POA
//
Policy[] policies = new Policy[6];
LifespanPolicyValueHelper.insert(any, LifespanPolicyValue.PERSISTENT);
policies[0] = orb.create_policy(LIFESPAN_POLICY_ID.value, any);
IdAssignmentPolicyValueHelper.insert(any, IdAssignmentPolicyValue.USER_ID);
policies[1] = orb.create_policy(ID_ASSIGNMENT_POLICY_ID.value, any);
RequestProcessingPolicyValueHelper.insert(any, RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
policies[2] = orb.create_policy(REQUEST_PROCESSING_POLICY_ID.value, any);
ServantRetentionPolicyValueHelper.insert(any, ServantRetentionPolicyValue.NON_RETAIN);
policies[3] = orb.create_policy(SERVANT_RETENTION_POLICY_ID.value, any);
ImplicitActivationPolicyValueHelper.insert(any, ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
policies[4] = orb.create_policy(IMPLICIT_ACTIVATION_POLICY_ID.value, any);
any.insert_long(10);
policies[5] = orb.create_policy(MY_SERVER_POLICY_ID.value, any);
POA persistentPOA = poa.create_POA("persistent", manager, policies);
//
// Create implementation objects
//
TestInterface_impl impl = new TestInterface_impl(orb, persistentPOA);
byte[] oid = ("test").getBytes();
org.omg.CORBA.Object objImpl = persistentPOA.create_reference_with_id(oid, "IDL:TestInterface:1.0");
TestInterfaceDSI_impl dsiImpl = new TestInterfaceDSI_impl(orb, persistentPOA);
oid = ("testDSI").getBytes();
org.omg.CORBA.Object objDSIImpl = persistentPOA.create_reference_with_id(oid, "IDL:TestInterface:1.0");
locatorImpl = new TestLocator_impl(orb, impl, dsiImpl);
ServantLocator locator = locatorImpl._this(orb);
persistentPOA.set_servant_manager(locator);
org.omg.IOP.CodecFactory factory = org.omg.IOP.CodecFactoryHelper.narrow(orb.resolve_initial_references("CodecFactory"));
assertTrue(factory != null);
ServerRequestInterceptor interceptor = new ServerTestInterceptor_impl(orb, factory);
ServerORBInitializer_impl.serverProxyManager.setInterceptor(0, interceptor);
System.out.println("About to write refs");
//
// Save references. This must be done after POA manager
// activation, otherwise there is a potential for a race
// condition between the client sending request and the server
// not being ready yet.
//
writeRef(orb, out, objImpl);
writeRef(orb, out, objDSIImpl);
out.flush();
System.out.println("Wrote refs");
if (!nonBlocking) {
//
// Give up control to the ORB
//
System.out.println("About to call orb.run()");
orb.run();
System.out.println("orb.run() returned");
//
// Clean up
//
ServerCleanup();
}
return;
} catch (Throwable e) {
e.printStackTrace(out);
e.printStackTrace(System.out);
throw e;
}
}
}
protected static void writeRef(ORB orb, PrintWriter out, org.omg.CORBA.Object objImpl) {
out.println("ref:");
out.println(orb.object_to_string(objImpl));
}
static void ServerCleanup() {
File file = new File(refFile);
file.delete();
}
public static void main(String[] args) throws Exception {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
ORB orb = null;
try {
ServerRegisterInterceptors(props);
props.put("yoko.orb.id", "myORB");
orb = ORB.init(args, props);
ServerRun(orb, false, args);
} finally {
if (orb != null) {
orb.destroy();
}
}
}
}
| 5,719 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/TranslateCallInterceptor_impl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
import org.omg.CORBA.*;
import org.omg.PortableInterceptor.*;
import test.pi.TestInterfacePackage.*;
final class TranslateCallInterceptor_impl extends org.omg.CORBA.LocalObject
implements ClientRequestInterceptor {
//
// From TestBase (no multiple inheritance)
//
public static void TEST(boolean expr) {
if (!expr)
throw new test.common.TestException();
}
private SystemException requestEx_;
private SystemException replyEx_;
private SystemException exceptionEx_;
private SystemException expected_;
public String name() {
return "CRI";
}
public void destroy() {
}
public void send_request(ClientRequestInfo ri) {
if (requestEx_ != null)
throw requestEx_;
}
public void send_poll(ClientRequestInfo ri) {
}
public void receive_reply(ClientRequestInfo ri) {
TEST(expected_ == null);
if (replyEx_ != null)
throw replyEx_;
}
public void receive_other(ClientRequestInfo ri) {
}
public void receive_exception(ClientRequestInfo ri) {
if (expected_ != null) {
Any any = ri.received_exception();
org.omg.CORBA.portable.InputStream in = any.create_input_stream();
SystemException ex = org.apache.yoko.orb.OB.Util
.unmarshalSystemException(in);
TEST(expected_.getClass().getName().equals(ex.getClass().getName()));
}
if (exceptionEx_ != null)
throw exceptionEx_;
}
void throwOnRequest(SystemException ex) {
requestEx_ = ex;
}
void noThrowOnRequest() {
requestEx_ = null;
}
void throwOnReply(SystemException ex) {
replyEx_ = ex;
}
void noThrowOnReply() {
replyEx_ = null;
}
void throwOnException(SystemException ex) {
exceptionEx_ = ex;
}
void noThrowOnException() {
exceptionEx_ = null;
}
void expectException(SystemException ex) {
expected_ = ex;
}
void noExpectedException() {
expected_ = null;
}
}
| 5,720 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/MyClientPolicyFactory_impl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
import org.omg.CORBA.*;
import org.omg.PortableInterceptor.*;
final class MyClientPolicyFactory_impl extends org.omg.CORBA.LocalObject
implements PolicyFactory {
//
// IDL to Java Mapping
//
public Policy create_policy(int type, Any any) throws PolicyError {
if (type == MY_CLIENT_POLICY_ID.value) {
try {
int val = any.extract_long();
return new MyClientPolicy_impl(val);
} catch (BAD_OPERATION ex) {
}
throw new PolicyError(BAD_POLICY_TYPE.value);
}
throw new PolicyError(BAD_POLICY.value);
}
}
| 5,721 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/TestInterfaceHelper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:TestInterface:1.0
//
final public class TestInterfaceHelper
{
public static void
insert(org.omg.CORBA.Any any, TestInterface val)
{
any.insert_Object(val, type());
}
public static TestInterface
extract(org.omg.CORBA.Any any)
{
if(any.type().equivalent(type()))
return narrow(any.extract_Object());
throw new org.omg.CORBA.BAD_OPERATION();
}
private static org.omg.CORBA.TypeCode typeCode_;
public static org.omg.CORBA.TypeCode
type()
{
if(typeCode_ == null)
{
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
typeCode_ = orb.create_interface_tc(id(), "TestInterface");
}
return typeCode_;
}
public static String
id()
{
return "IDL:TestInterface:1.0";
}
public static TestInterface
read(org.omg.CORBA.portable.InputStream in)
{
org.omg.CORBA.Object _ob_v = in.read_Object();
try
{
return (TestInterface)_ob_v;
}
catch(ClassCastException ex)
{
}
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)_ob_v;
_TestInterfaceStub _ob_stub = new _TestInterfaceStub();
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
public static void
write(org.omg.CORBA.portable.OutputStream out, TestInterface val)
{
out.write_Object(val);
}
public static TestInterface
narrow(org.omg.CORBA.Object val)
{
if(val != null)
{
try
{
return (TestInterface)val;
}
catch(ClassCastException ex)
{
}
if(val._is_a(id()))
{
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_TestInterfaceStub _ob_stub = new _TestInterfaceStub();
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)val;
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
throw new org.omg.CORBA.BAD_PARAM();
}
return null;
}
public static TestInterface
unchecked_narrow(org.omg.CORBA.Object val)
{
if(val != null)
{
try
{
return (TestInterface)val;
}
catch(ClassCastException ex)
{
}
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_TestInterfaceStub _ob_stub = new _TestInterfaceStub();
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)val;
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
return null;
}
}
| 5,722 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/MyClientPolicyOperations.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:MyClientPolicy:1.0
//
/***/
public interface MyClientPolicyOperations extends org.omg.CORBA.PolicyOperations
{
//
// IDL:MyClientPolicy/value:1.0
//
/***/
int
value();
}
| 5,723 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/fooHolder.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:foo:1.0
//
final public class fooHolder implements org.omg.CORBA.portable.Streamable
{
public foo value;
public
fooHolder()
{
}
public
fooHolder(foo initial)
{
value = initial;
}
public void
_read(org.omg.CORBA.portable.InputStream in)
{
value = fooHelper.read(in);
}
public void
_write(org.omg.CORBA.portable.OutputStream out)
{
fooHelper.write(out, value);
}
public org.omg.CORBA.TypeCode
_type()
{
return fooHelper.type();
}
}
| 5,724 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/MY_CLIENT_POLICY_ID.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:MY_CLIENT_POLICY_ID:1.0
//
/***/
public interface MY_CLIENT_POLICY_ID
{
int value = (int)(1011L);
}
| 5,725 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/MyServerPolicy_impl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableInterceptor.*;
final class MyServerPolicy_impl extends org.omg.CORBA.LocalObject implements
MyServerPolicy {
private int value_;
MyServerPolicy_impl(int value) {
value_ = value;
}
//
// Standard IDL to Java Mapping
//
public int value() {
return value_;
}
public int policy_type() {
return MY_SERVER_POLICY_ID.value;
}
public Policy copy() {
// TODO: Is this sufficient here?
return this;
}
public void destroy() {
}
}
| 5,726 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/TestInterfacePOA.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:TestInterface:1.0
//
public abstract class TestInterfacePOA
extends org.apache.yoko.orb.PortableServer.Servant
implements TestInterfaceOperations
{
static final String[] _ob_ids_ =
{
"IDL:TestInterface:1.0",
};
public TestInterface
_this()
{
return TestInterfaceHelper.narrow(super._this_object());
}
public TestInterface
_this(org.omg.CORBA.ORB orb)
{
return TestInterfaceHelper.narrow(super._this_object(orb));
}
public String[]
_all_interfaces(org.omg.PortableServer.POA poa, byte[] objectId)
{
return _ob_ids_;
}
public void
_OB_dispatch(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
final String _ob_op = _ob_up.operation();
final String[] _ob_names =
{
"_get_string_attrib",
"_get_struct_attrib",
"_set_string_attrib",
"_set_struct_attrib",
"deactivate",
"location_forward",
"noargs",
"noargs_oneway",
"one_string_in",
"one_string_inout",
"one_string_out",
"one_string_return",
"one_struct_in",
"one_struct_inout",
"one_struct_out",
"one_struct_return",
"systemexception",
"test_service_context",
"userexception"
};
int _ob_left = 0;
int _ob_right = _ob_names.length;
int _ob_index = -1;
while(_ob_left < _ob_right)
{
int _ob_m = (_ob_left + _ob_right) / 2;
int _ob_res = _ob_names[_ob_m].compareTo(_ob_op);
if(_ob_res == 0)
{
_ob_index = _ob_m;
break;
}
else if(_ob_res > 0)
_ob_right = _ob_m;
else
_ob_left = _ob_m + 1;
}
if(_ob_index == -1 && _ob_op.charAt(0) == '_')
{
_ob_left = 0;
_ob_right = _ob_names.length;
String _ob_ami_op =
_ob_op.substring(1);
while(_ob_left < _ob_right)
{
int _ob_m = (_ob_left + _ob_right) / 2;
int _ob_res = _ob_names[_ob_m].compareTo(_ob_ami_op);
if(_ob_res == 0)
{
_ob_index = _ob_m;
break;
}
else if(_ob_res > 0)
_ob_right = _ob_m;
else
_ob_left = _ob_m + 1;
}
}
switch(_ob_index)
{
case 0: // _get_string_attrib
_OB_att_get_string_attrib(_ob_up);
return;
case 1: // _get_struct_attrib
_OB_att_get_struct_attrib(_ob_up);
return;
case 2: // _set_string_attrib
_OB_att_set_string_attrib(_ob_up);
return;
case 3: // _set_struct_attrib
_OB_att_set_struct_attrib(_ob_up);
return;
case 4: // deactivate
_OB_op_deactivate(_ob_up);
return;
case 5: // location_forward
_OB_op_location_forward(_ob_up);
return;
case 6: // noargs
_OB_op_noargs(_ob_up);
return;
case 7: // noargs_oneway
_OB_op_noargs_oneway(_ob_up);
return;
case 8: // one_string_in
_OB_op_one_string_in(_ob_up);
return;
case 9: // one_string_inout
_OB_op_one_string_inout(_ob_up);
return;
case 10: // one_string_out
_OB_op_one_string_out(_ob_up);
return;
case 11: // one_string_return
_OB_op_one_string_return(_ob_up);
return;
case 12: // one_struct_in
_OB_op_one_struct_in(_ob_up);
return;
case 13: // one_struct_inout
_OB_op_one_struct_inout(_ob_up);
return;
case 14: // one_struct_out
_OB_op_one_struct_out(_ob_up);
return;
case 15: // one_struct_return
_OB_op_one_struct_return(_ob_up);
return;
case 16: // systemexception
_OB_op_systemexception(_ob_up);
return;
case 17: // test_service_context
_OB_op_test_service_context(_ob_up);
return;
case 18: // userexception
_OB_op_userexception(_ob_up);
return;
}
throw new org.omg.CORBA.BAD_OPERATION();
}
private void
_OB_att_get_string_attrib(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
org.omg.CORBA.StringHolder _ob_rh = new org.omg.CORBA.StringHolder();
org.apache.yoko.orb.OB.ParameterDesc _ob_retDesc = new org.apache.yoko.orb.OB.ParameterDesc(_ob_rh, _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string), 0);
_OB_preUnmarshal(_ob_up);
_OB_setArgDesc(_ob_up, null, _ob_retDesc, null);
_OB_postUnmarshal(_ob_up);
_ob_rh.value = string_attrib();
_OB_postinvoke(_ob_up);
org.omg.CORBA.portable.OutputStream out = _OB_preMarshal(_ob_up);
try
{
out.write_string(_ob_rh.value);
}
catch(org.omg.CORBA.SystemException _ob_ex)
{
_OB_marshalEx(_ob_up, _ob_ex);
}
_OB_postMarshal(_ob_up);
}
private void
_OB_att_get_struct_attrib(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
test.pi.TestInterfacePackage.sHolder _ob_rh = new test.pi.TestInterfacePackage.sHolder();
org.apache.yoko.orb.OB.ParameterDesc _ob_retDesc = new org.apache.yoko.orb.OB.ParameterDesc(_ob_rh, test.pi.TestInterfacePackage.sHelper.type(), 0);
_OB_preUnmarshal(_ob_up);
_OB_setArgDesc(_ob_up, null, _ob_retDesc, null);
_OB_postUnmarshal(_ob_up);
_ob_rh.value = struct_attrib();
_OB_postinvoke(_ob_up);
org.omg.CORBA.portable.OutputStream out = _OB_preMarshal(_ob_up);
try
{
test.pi.TestInterfacePackage.sHelper.write(out, _ob_rh.value);
}
catch(org.omg.CORBA.SystemException _ob_ex)
{
_OB_marshalEx(_ob_up, _ob_ex);
}
_OB_postMarshal(_ob_up);
}
private void
_OB_att_set_string_attrib(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
org.omg.CORBA.StringHolder _ob_ah = new org.omg.CORBA.StringHolder();
org.omg.CORBA.portable.InputStream in = _OB_preUnmarshal(_ob_up);
try
{
_ob_ah.value = in.read_string();
}
catch(org.omg.CORBA.SystemException _ob_ex)
{
_OB_unmarshalEx(_ob_up, _ob_ex);
}
org.apache.yoko.orb.OB.ParameterDesc[] _ob_desc =
{
new org.apache.yoko.orb.OB.ParameterDesc(_ob_ah, _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string), 0)
};
_OB_setArgDesc(_ob_up, _ob_desc, null, null);
_OB_postUnmarshal(_ob_up);
string_attrib(_ob_ah.value);
_OB_postinvoke(_ob_up);
_OB_preMarshal(_ob_up);
_OB_postMarshal(_ob_up);
}
private void
_OB_att_set_struct_attrib(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
test.pi.TestInterfacePackage.sHolder _ob_ah = new test.pi.TestInterfacePackage.sHolder();
org.omg.CORBA.portable.InputStream in = _OB_preUnmarshal(_ob_up);
try
{
_ob_ah.value = test.pi.TestInterfacePackage.sHelper.read(in);
}
catch(org.omg.CORBA.SystemException _ob_ex)
{
_OB_unmarshalEx(_ob_up, _ob_ex);
}
org.apache.yoko.orb.OB.ParameterDesc[] _ob_desc =
{
new org.apache.yoko.orb.OB.ParameterDesc(_ob_ah, test.pi.TestInterfacePackage.sHelper.type(), 0)
};
_OB_setArgDesc(_ob_up, _ob_desc, null, null);
_OB_postUnmarshal(_ob_up);
struct_attrib(_ob_ah.value);
_OB_postinvoke(_ob_up);
_OB_preMarshal(_ob_up);
_OB_postMarshal(_ob_up);
}
private void
_OB_op_deactivate(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
_OB_preUnmarshal(_ob_up);
_OB_setArgDesc(_ob_up, null, null, null);
_OB_postUnmarshal(_ob_up);
deactivate();
_OB_postinvoke(_ob_up);
_OB_preMarshal(_ob_up);
_OB_postMarshal(_ob_up);
}
private void
_OB_op_location_forward(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
_OB_preUnmarshal(_ob_up);
_OB_setArgDesc(_ob_up, null, null, null);
_OB_postUnmarshal(_ob_up);
location_forward();
_OB_postinvoke(_ob_up);
_OB_preMarshal(_ob_up);
_OB_postMarshal(_ob_up);
}
private void
_OB_op_noargs(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
_OB_preUnmarshal(_ob_up);
_OB_setArgDesc(_ob_up, null, null, null);
_OB_postUnmarshal(_ob_up);
noargs();
_OB_postinvoke(_ob_up);
_OB_preMarshal(_ob_up);
_OB_postMarshal(_ob_up);
}
private void
_OB_op_noargs_oneway(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
_OB_preUnmarshal(_ob_up);
_OB_setArgDesc(_ob_up, null, null, null);
_OB_postUnmarshal(_ob_up);
noargs_oneway();
_OB_postinvoke(_ob_up);
_OB_preMarshal(_ob_up);
_OB_postMarshal(_ob_up);
}
private void
_OB_op_one_string_in(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
org.omg.CORBA.StringHolder _ob_ah0 = new org.omg.CORBA.StringHolder();
org.omg.CORBA.portable.InputStream in = _OB_preUnmarshal(_ob_up);
try
{
_ob_ah0.value = in.read_string();
}
catch(org.omg.CORBA.SystemException _ob_ex)
{
_OB_unmarshalEx(_ob_up, _ob_ex);
}
org.apache.yoko.orb.OB.ParameterDesc[] _ob_desc =
{
new org.apache.yoko.orb.OB.ParameterDesc(_ob_ah0, _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string), 0) /*in*/
};
_OB_setArgDesc(_ob_up, _ob_desc, null, null);
_OB_postUnmarshal(_ob_up);
one_string_in(_ob_ah0.value);
_OB_postinvoke(_ob_up);
_OB_preMarshal(_ob_up);
_OB_postMarshal(_ob_up);
}
private void
_OB_op_one_string_inout(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
org.omg.CORBA.StringHolder _ob_ah0 = new org.omg.CORBA.StringHolder();
org.omg.CORBA.portable.InputStream in = _OB_preUnmarshal(_ob_up);
try
{
_ob_ah0.value = in.read_string();
}
catch(org.omg.CORBA.SystemException _ob_ex)
{
_OB_unmarshalEx(_ob_up, _ob_ex);
}
org.apache.yoko.orb.OB.ParameterDesc[] _ob_desc =
{
new org.apache.yoko.orb.OB.ParameterDesc(_ob_ah0, _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string), 2) /*inout*/
};
_OB_setArgDesc(_ob_up, _ob_desc, null, null);
_OB_postUnmarshal(_ob_up);
one_string_inout(_ob_ah0);
_OB_postinvoke(_ob_up);
org.omg.CORBA.portable.OutputStream out = _OB_preMarshal(_ob_up);
try
{
out.write_string(_ob_ah0.value);
}
catch(org.omg.CORBA.SystemException _ob_ex)
{
_OB_marshalEx(_ob_up, _ob_ex);
}
_OB_postMarshal(_ob_up);
}
private void
_OB_op_one_string_out(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
org.omg.CORBA.StringHolder _ob_ah0 = new org.omg.CORBA.StringHolder();
_OB_preUnmarshal(_ob_up);
org.apache.yoko.orb.OB.ParameterDesc[] _ob_desc =
{
new org.apache.yoko.orb.OB.ParameterDesc(_ob_ah0, _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string), 1) /*out*/
};
_OB_setArgDesc(_ob_up, _ob_desc, null, null);
_OB_postUnmarshal(_ob_up);
one_string_out(_ob_ah0);
_OB_postinvoke(_ob_up);
org.omg.CORBA.portable.OutputStream out = _OB_preMarshal(_ob_up);
try
{
out.write_string(_ob_ah0.value);
}
catch(org.omg.CORBA.SystemException _ob_ex)
{
_OB_marshalEx(_ob_up, _ob_ex);
}
_OB_postMarshal(_ob_up);
}
private void
_OB_op_one_string_return(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
_OB_preUnmarshal(_ob_up);
org.omg.CORBA.StringHolder _ob_rh = new org.omg.CORBA.StringHolder();
org.apache.yoko.orb.OB.ParameterDesc _ob_retDesc = new org.apache.yoko.orb.OB.ParameterDesc(_ob_rh, _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string), 0);
_OB_setArgDesc(_ob_up, null, _ob_retDesc, null);
_OB_postUnmarshal(_ob_up);
_ob_rh.value = one_string_return();
_OB_postinvoke(_ob_up);
org.omg.CORBA.portable.OutputStream out = _OB_preMarshal(_ob_up);
try
{
out.write_string(_ob_rh.value);
}
catch(org.omg.CORBA.SystemException _ob_ex)
{
_OB_marshalEx(_ob_up, _ob_ex);
}
_OB_postMarshal(_ob_up);
}
private void
_OB_op_one_struct_in(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
test.pi.TestInterfacePackage.sHolder _ob_ah0 = new test.pi.TestInterfacePackage.sHolder();
org.omg.CORBA.portable.InputStream in = _OB_preUnmarshal(_ob_up);
try
{
_ob_ah0.value = test.pi.TestInterfacePackage.sHelper.read(in);
}
catch(org.omg.CORBA.SystemException _ob_ex)
{
_OB_unmarshalEx(_ob_up, _ob_ex);
}
org.apache.yoko.orb.OB.ParameterDesc[] _ob_desc =
{
new org.apache.yoko.orb.OB.ParameterDesc(_ob_ah0, test.pi.TestInterfacePackage.sHelper.type(), 0) /*in*/
};
_OB_setArgDesc(_ob_up, _ob_desc, null, null);
_OB_postUnmarshal(_ob_up);
one_struct_in(_ob_ah0.value);
_OB_postinvoke(_ob_up);
_OB_preMarshal(_ob_up);
_OB_postMarshal(_ob_up);
}
private void
_OB_op_one_struct_inout(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
test.pi.TestInterfacePackage.sHolder _ob_ah0 = new test.pi.TestInterfacePackage.sHolder();
org.omg.CORBA.portable.InputStream in = _OB_preUnmarshal(_ob_up);
try
{
_ob_ah0.value = test.pi.TestInterfacePackage.sHelper.read(in);
}
catch(org.omg.CORBA.SystemException _ob_ex)
{
_OB_unmarshalEx(_ob_up, _ob_ex);
}
org.apache.yoko.orb.OB.ParameterDesc[] _ob_desc =
{
new org.apache.yoko.orb.OB.ParameterDesc(_ob_ah0, test.pi.TestInterfacePackage.sHelper.type(), 2) /*inout*/
};
_OB_setArgDesc(_ob_up, _ob_desc, null, null);
_OB_postUnmarshal(_ob_up);
one_struct_inout(_ob_ah0);
_OB_postinvoke(_ob_up);
org.omg.CORBA.portable.OutputStream out = _OB_preMarshal(_ob_up);
try
{
test.pi.TestInterfacePackage.sHelper.write(out, _ob_ah0.value);
}
catch(org.omg.CORBA.SystemException _ob_ex)
{
_OB_marshalEx(_ob_up, _ob_ex);
}
_OB_postMarshal(_ob_up);
}
private void
_OB_op_one_struct_out(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
test.pi.TestInterfacePackage.sHolder _ob_ah0 = new test.pi.TestInterfacePackage.sHolder();
_OB_preUnmarshal(_ob_up);
org.apache.yoko.orb.OB.ParameterDesc[] _ob_desc =
{
new org.apache.yoko.orb.OB.ParameterDesc(_ob_ah0, test.pi.TestInterfacePackage.sHelper.type(), 1) /*out*/
};
_OB_setArgDesc(_ob_up, _ob_desc, null, null);
_OB_postUnmarshal(_ob_up);
one_struct_out(_ob_ah0);
_OB_postinvoke(_ob_up);
org.omg.CORBA.portable.OutputStream out = _OB_preMarshal(_ob_up);
try
{
test.pi.TestInterfacePackage.sHelper.write(out, _ob_ah0.value);
}
catch(org.omg.CORBA.SystemException _ob_ex)
{
_OB_marshalEx(_ob_up, _ob_ex);
}
_OB_postMarshal(_ob_up);
}
private void
_OB_op_one_struct_return(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
_OB_preUnmarshal(_ob_up);
test.pi.TestInterfacePackage.sHolder _ob_rh = new test.pi.TestInterfacePackage.sHolder();
org.apache.yoko.orb.OB.ParameterDesc _ob_retDesc = new org.apache.yoko.orb.OB.ParameterDesc(_ob_rh, test.pi.TestInterfacePackage.sHelper.type(), 0);
_OB_setArgDesc(_ob_up, null, _ob_retDesc, null);
_OB_postUnmarshal(_ob_up);
_ob_rh.value = one_struct_return();
_OB_postinvoke(_ob_up);
org.omg.CORBA.portable.OutputStream out = _OB_preMarshal(_ob_up);
try
{
test.pi.TestInterfacePackage.sHelper.write(out, _ob_rh.value);
}
catch(org.omg.CORBA.SystemException _ob_ex)
{
_OB_marshalEx(_ob_up, _ob_ex);
}
_OB_postMarshal(_ob_up);
}
private void
_OB_op_systemexception(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
_OB_preUnmarshal(_ob_up);
_OB_setArgDesc(_ob_up, null, null, null);
_OB_postUnmarshal(_ob_up);
systemexception();
_OB_postinvoke(_ob_up);
_OB_preMarshal(_ob_up);
_OB_postMarshal(_ob_up);
}
private void
_OB_op_test_service_context(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
_OB_preUnmarshal(_ob_up);
_OB_setArgDesc(_ob_up, null, null, null);
_OB_postUnmarshal(_ob_up);
test_service_context();
_OB_postinvoke(_ob_up);
_OB_preMarshal(_ob_up);
_OB_postMarshal(_ob_up);
}
private void
_OB_op_userexception(org.apache.yoko.orb.OB.Upcall _ob_up)
throws org.apache.yoko.orb.OB.LocationForward
{
_OB_preUnmarshal(_ob_up);
org.omg.CORBA.TypeCode[] _ob_exceptions =
{
test.pi.TestInterfacePackage.userHelper.type()
};
_OB_setArgDesc(_ob_up, null, null, _ob_exceptions);
_OB_postUnmarshal(_ob_up);
try
{
userexception();
_OB_postinvoke(_ob_up);
_OB_preMarshal(_ob_up);
_OB_postMarshal(_ob_up);
}
catch(test.pi.TestInterfacePackage.user _ob_ex)
{
org.omg.CORBA.portable.OutputStream out = _OB_beginUserException(_ob_up, _ob_ex);
if(out != null)
test.pi.TestInterfacePackage.userHelper.write(out, _ob_ex);
}
}
}
| 5,727 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/TestInterfaceOperations.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:TestInterface:1.0
//
/***/
public interface TestInterfaceOperations
{
//
// IDL:TestInterface/noargs:1.0
//
/***/
void
noargs();
//
// IDL:TestInterface/noargs_oneway:1.0
//
/***/
void
noargs_oneway();
//
// IDL:TestInterface/systemexception:1.0
//
/***/
void
systemexception();
//
// IDL:TestInterface/userexception:1.0
//
/***/
void
userexception()
throws test.pi.TestInterfacePackage.user;
//
// IDL:TestInterface/location_forward:1.0
//
/***/
void
location_forward();
//
// IDL:TestInterface/test_service_context:1.0
//
/***/
void
test_service_context();
//
// IDL:TestInterface/string_attrib:1.0
//
/***/
String
string_attrib();
void
string_attrib(String val);
//
// IDL:TestInterface/one_string_in:1.0
//
/***/
void
one_string_in(String param);
//
// IDL:TestInterface/one_string_inout:1.0
//
/***/
void
one_string_inout(org.omg.CORBA.StringHolder param);
//
// IDL:TestInterface/one_string_out:1.0
//
/***/
void
one_string_out(org.omg.CORBA.StringHolder param);
//
// IDL:TestInterface/one_string_return:1.0
//
/***/
String
one_string_return();
//
// IDL:TestInterface/struct_attrib:1.0
//
/***/
test.pi.TestInterfacePackage.s
struct_attrib();
void
struct_attrib(test.pi.TestInterfacePackage.s val);
//
// IDL:TestInterface/one_struct_in:1.0
//
/***/
void
one_struct_in(test.pi.TestInterfacePackage.s param);
//
// IDL:TestInterface/one_struct_inout:1.0
//
/***/
void
one_struct_inout(test.pi.TestInterfacePackage.sHolder param);
//
// IDL:TestInterface/one_struct_out:1.0
//
/***/
void
one_struct_out(test.pi.TestInterfacePackage.sHolder param);
//
// IDL:TestInterface/one_struct_return:1.0
//
/***/
test.pi.TestInterfacePackage.s
one_struct_return();
//
// IDL:TestInterface/deactivate:1.0
//
/***/
void
deactivate();
}
| 5,728 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/fooHelper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:foo:1.0
//
final public class fooHelper
{
public static void
insert(org.omg.CORBA.Any any, foo val)
{
org.omg.CORBA.portable.OutputStream out = any.create_output_stream();
write(out, val);
any.read_value(out.create_input_stream(), type());
}
public static foo
extract(org.omg.CORBA.Any any)
{
if(any.type().equivalent(type()))
return read(any.create_input_stream());
else
throw new org.omg.CORBA.BAD_OPERATION();
}
private static org.omg.CORBA.TypeCode typeCode_;
public static org.omg.CORBA.TypeCode
type()
{
if(typeCode_ == null)
{
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
org.omg.CORBA.StructMember[] members = new org.omg.CORBA.StructMember[1];
members[0] = new org.omg.CORBA.StructMember();
members[0].name = "l";
members[0].type = orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_long);
typeCode_ = orb.create_struct_tc(id(), "foo", members);
}
return typeCode_;
}
public static String
id()
{
return "IDL:foo:1.0";
}
public static foo
read(org.omg.CORBA.portable.InputStream in)
{
foo _ob_v = new foo();
_ob_v.l = in.read_long();
return _ob_v;
}
public static void
write(org.omg.CORBA.portable.OutputStream out, foo val)
{
out.write_long(val.l);
}
}
| 5,729 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/REPLY_CONTEXT_2_ID.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi;
//
// IDL:REPLY_CONTEXT_2_ID:1.0
//
/***/
public interface REPLY_CONTEXT_2_ID
{
int value = (int)(102L);
}
| 5,730 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/TestInterfacePackage/user.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi.TestInterfacePackage;
//
// IDL:TestInterface/user:1.0
//
/***/
final public class user extends org.omg.CORBA.UserException
{
private static final String _ob_id = "IDL:TestInterface/user:1.0";
public
user()
{
super(_ob_id);
}
public
user(String _reason)
{
super(_ob_id + " " + _reason);
}
}
| 5,731 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/TestInterfacePackage/userHelper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi.TestInterfacePackage;
//
// IDL:TestInterface/user:1.0
//
final public class userHelper
{
public static void
insert(org.omg.CORBA.Any any, user val)
{
org.omg.CORBA.portable.OutputStream out = any.create_output_stream();
write(out, val);
any.read_value(out.create_input_stream(), type());
}
public static user
extract(org.omg.CORBA.Any any)
{
if(any.type().equivalent(type()))
return read(any.create_input_stream());
else
throw new org.omg.CORBA.BAD_OPERATION();
}
private static org.omg.CORBA.TypeCode typeCode_;
public static org.omg.CORBA.TypeCode
type()
{
if(typeCode_ == null)
{
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
org.omg.CORBA.StructMember[] members = new org.omg.CORBA.StructMember[0];
typeCode_ = orb.create_exception_tc(id(), "user", members);
}
return typeCode_;
}
public static String
id()
{
return "IDL:TestInterface/user:1.0";
}
public static user
read(org.omg.CORBA.portable.InputStream in)
{
if(!id().equals(in.read_string()))
throw new org.omg.CORBA.MARSHAL();
user _ob_v = new user();
return _ob_v;
}
public static void
write(org.omg.CORBA.portable.OutputStream out, user val)
{
out.write_string(id());
}
}
| 5,732 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/TestInterfacePackage/s.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi.TestInterfacePackage;
//
// IDL:TestInterface/s:1.0
//
/***/
final public class s implements org.omg.CORBA.portable.IDLEntity
{
private static final String _ob_id = "IDL:TestInterface/s:1.0";
public
s()
{
}
public
s(String sval)
{
this.sval = sval;
}
public String sval;
}
| 5,733 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/TestInterfacePackage/userHolder.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi.TestInterfacePackage;
//
// IDL:TestInterface/user:1.0
//
final public class userHolder implements org.omg.CORBA.portable.Streamable
{
public user value;
public
userHolder()
{
}
public
userHolder(user initial)
{
value = initial;
}
public void
_read(org.omg.CORBA.portable.InputStream in)
{
value = userHelper.read(in);
}
public void
_write(org.omg.CORBA.portable.OutputStream out)
{
userHelper.write(out, value);
}
public org.omg.CORBA.TypeCode
_type()
{
return userHelper.type();
}
}
| 5,734 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/TestInterfacePackage/sHelper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi.TestInterfacePackage;
//
// IDL:TestInterface/s:1.0
//
final public class sHelper
{
public static void
insert(org.omg.CORBA.Any any, s val)
{
org.omg.CORBA.portable.OutputStream out = any.create_output_stream();
write(out, val);
any.read_value(out.create_input_stream(), type());
}
public static s
extract(org.omg.CORBA.Any any)
{
if(any.type().equivalent(type()))
return read(any.create_input_stream());
else
throw new org.omg.CORBA.BAD_OPERATION();
}
private static org.omg.CORBA.TypeCode typeCode_;
public static org.omg.CORBA.TypeCode
type()
{
if(typeCode_ == null)
{
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
org.omg.CORBA.StructMember[] members = new org.omg.CORBA.StructMember[1];
members[0] = new org.omg.CORBA.StructMember();
members[0].name = "sval";
members[0].type = orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_string);
typeCode_ = orb.create_struct_tc(id(), "s", members);
}
return typeCode_;
}
public static String
id()
{
return "IDL:TestInterface/s:1.0";
}
public static s
read(org.omg.CORBA.portable.InputStream in)
{
s _ob_v = new s();
_ob_v.sval = in.read_string();
return _ob_v;
}
public static void
write(org.omg.CORBA.portable.OutputStream out, s val)
{
out.write_string(val.sval);
}
}
| 5,735 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/pi/TestInterfacePackage/sHolder.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.pi.TestInterfacePackage;
//
// IDL:TestInterface/s:1.0
//
final public class sHolder implements org.omg.CORBA.portable.Streamable
{
public s value;
public
sHolder()
{
}
public
sHolder(s initial)
{
value = initial;
}
public void
_read(org.omg.CORBA.portable.InputStream in)
{
value = sHelper.read(in);
}
public void
_write(org.omg.CORBA.portable.OutputStream out)
{
sHelper.write(out, value);
}
public org.omg.CORBA.TypeCode
_type()
{
return sHelper.type();
}
}
| 5,736 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/common/TestException.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.common;
public class TestException extends RuntimeException {
}
| 5,737 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/common/TestBase.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.common;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.rmi.Remote;
import javax.rmi.PortableRemoteObject;
import org.omg.CORBA.ORB;
import org.omg.CORBA.portable.IDLEntity;
import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextPackage.InvalidName;
public class TestBase {
public static org.omg.CORBA.TypeCode getOrigType(org.omg.CORBA.TypeCode tc) {
org.omg.CORBA.TypeCode result = tc;
try {
while (result.kind() == org.omg.CORBA.TCKind.tk_alias)
result = result.content_type();
} catch (org.omg.CORBA.TypeCodePackage.BadKind ex) {
throw new AssertionError(ex);
}
return result;
}
protected static void writeRef(ORB orb, PrintWriter out, org.omg.CORBA.Object obj,
NamingContextExt context, NameComponent[] name) throws InvalidName {
writeRef(orb, out, obj, context.to_string(name));
}
private static void writeRef(ORB orb, PrintWriter out, org.omg.CORBA.Object obj, String name) {
out.println("ref:");
out.println(orb.object_to_string(obj));
out.println(name);
}
protected static void writeRef(ORB orb, PrintWriter out, org.omg.CORBA.Object obj) {
writeRef(orb, out, obj, "");
}
protected static String[] readRef(BufferedReader reader, String[] refStrings) throws IOException {
String line = reader.readLine();
if (line == null) {
throw new RuntimeException("Unknown Server error");
} else if (!!!line.equals("ref:")) {
try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) {
pw.println("Server error:");
do {
pw.print('\t');
pw.println(line);
} while ((line = reader.readLine()) != null);
pw.flush();
throw new RuntimeException(sw.toString());
}
}
refStrings[0] = reader.readLine();
refStrings[1] = reader.readLine();
return refStrings;
}
private static org.omg.CORBA.Object readGenericStub(ORB orb, BufferedReader reader) throws IOException {
return orb.string_to_object(readRef(reader, new String[2])[0]);
}
@SuppressWarnings("unchecked")
protected static<T extends Remote> T readRmiStub(ORB orb, BufferedReader reader, Class<T> type) throws ClassCastException, IOException {
return (T)PortableRemoteObject.narrow(readGenericStub(orb, reader), type);
}
@SuppressWarnings("unchecked")
protected static<T extends IDLEntity> T readIdlStub(ORB orb, BufferedReader reader, Class<T> type) throws ClassCastException, IOException {
return (T)PortableRemoteObject.narrow(readGenericStub(orb, reader), type);
}
protected static BufferedReader openFileReader(final String refFile) throws FileNotFoundException {
return new BufferedReader(new FileReader(refFile)) {
@Override
public void close() throws IOException {
try {
super.close();
} finally {
Files.delete(Paths.get(refFile));
}
}
};
}
}
| 5,738 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestLocationForward.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestLocationForward:1.0
//
/***/
public interface TestLocationForward extends TestLocationForwardOperations,
Test,
org.omg.CORBA.portable.IDLEntity
{
}
| 5,739 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/POAManagerProxyOperations.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:POAManagerProxy:1.0
//
/***/
public interface POAManagerProxyOperations
{
//
// IDL:POAManagerProxy/activate:1.0
//
/***/
void
activate()
throws test.poa.POAManagerProxyPackage.AdapterInactive;
//
// IDL:POAManagerProxy/hold_requests:1.0
//
/***/
void
hold_requests(boolean wait_for_completion)
throws test.poa.POAManagerProxyPackage.AdapterInactive;
//
// IDL:POAManagerProxy/discard_requests:1.0
//
/***/
void
discard_requests(boolean wait_for_completion)
throws test.poa.POAManagerProxyPackage.AdapterInactive;
//
// IDL:POAManagerProxy/deactivate:1.0
//
/***/
void
deactivate(boolean etherealize_objects,
boolean wait_for_completion)
throws test.poa.POAManagerProxyPackage.AdapterInactive;
//
// IDL:POAManagerProxy/get_state:1.0
//
/***/
test.poa.POAManagerProxyPackage.State
get_state();
}
| 5,740 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestPOAManagerServer.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
import java.io.*;
public final class TestPOAManagerServer extends test.common.TestBase {
final static class POAManagerProxy_impl extends POAManagerProxyPOA {
private POAManager manager_;
POAManagerProxy_impl(POAManager manager) {
manager_ = manager;
}
//
// Mapping for PortableServer::POAManager
//
public void activate()
throws test.poa.POAManagerProxyPackage.AdapterInactive {
try {
manager_.activate();
} catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
throw new test.poa.POAManagerProxyPackage.AdapterInactive();
}
}
public void hold_requests(boolean a)
throws test.poa.POAManagerProxyPackage.AdapterInactive {
try {
manager_.hold_requests(a);
} catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
throw new test.poa.POAManagerProxyPackage.AdapterInactive();
}
}
public void discard_requests(boolean a)
throws test.poa.POAManagerProxyPackage.AdapterInactive {
try {
manager_.discard_requests(a);
} catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
throw new test.poa.POAManagerProxyPackage.AdapterInactive();
}
}
public void deactivate(boolean a, boolean b)
throws test.poa.POAManagerProxyPackage.AdapterInactive {
try {
manager_.deactivate(a, b);
} catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
throw new test.poa.POAManagerProxyPackage.AdapterInactive();
}
}
public test.poa.POAManagerProxyPackage.State get_state() {
return test.poa.POAManagerProxyPackage.State.from_int(manager_
.get_state().value());
}
}
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
ORB orb = null;
try {
//
// Create ORB
//
orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
POAManager manager = root.the_POAManager();
//
// Create POA w/ RETAIN. This POA should use a seperate
// POAManager.
//
Policy[] policies = new Policy[5];
policies[0] = root
.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[1] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
policies[2] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[3] = root
.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
policies[4] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
POA retain = null;
try {
retain = root.create_POA("retain", null, policies);
} catch (AdapterAlreadyExists | InvalidPolicy ex) {
throw new RuntimeException(ex);
}
POAManager retainManager = retain.the_POAManager();
POAManagerProxy_impl proxyImpl = new POAManagerProxy_impl(
retainManager);
POAManagerProxy proxy = proxyImpl._this(orb);
Test_impl testImpl = new Test_impl(orb, retain);
byte[] oid = ("test").getBytes();
try {
retain.activate_object_with_id(oid, testImpl);
} catch (ObjectAlreadyActive | ServantAlreadyActive | WrongPolicy ex) {
throw new RuntimeException(ex);
}
Test test = testImpl._this();
TestDSI_impl testDSIImpl = new TestDSI_impl(orb, retain);
byte[] oidDSI = ("testDSI").getBytes();
try {
retain.activate_object_with_id(oidDSI, testDSIImpl);
} catch (ObjectAlreadyActive | ServantAlreadyActive | WrongPolicy ex) {
throw new RuntimeException(ex);
}
org.omg.CORBA.Object objDSI = retain.create_reference_with_id(
oidDSI, "IDL:Test:1.0");
Test testDSI = TestHelper.narrow(objDSI);
//
// Create server
//
TestInfo[] info = new TestInfo[2];
info[0] = new TestInfo();
info[1] = new TestInfo();
info[0].obj = test;
info[0].except_id = "";
info[1].obj = testDSI;
info[1].except_id = "";
TestServer_impl serverImpl = new TestServer_impl(orb, info);
TestServer server = serverImpl._this(orb);
//
// If JTC is available spawn a thread to find out whether a
// method invocation on test is blocked until
// POAManager::activate() is called.
//
PMSTestThread t = new PMSTestThread(test);
t.start();
t.waitForStart();
//
// Run implementation. This should cause the blocked call in
// the thread to release.
//
try {
manager.activate();
retainManager.activate();
} catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
throw new RuntimeException(ex);
}
t.waitForEnd();
assertTrue(t.result == PMSTestThread.Result.SUCCESS);
new TestPOAManagerCommon(proxy, info);
//
// Don't write references until we're ready to run
//
// Save reference
//
String refFile = "Test.ref";
try {
FileOutputStream file = new FileOutputStream(refFile);
PrintWriter out = new PrintWriter(file);
out.println(orb.object_to_string(server));
out.flush();
file.close();
} catch (IOException ex) {
System.err.println("Can't write to `" + ex.getMessage() + "'");
System.exit(1);
}
//
// Save reference
//
String refFileMgr = "POAManagerProxy.ref";
try {
FileOutputStream file = new FileOutputStream(refFileMgr);
PrintWriter out = new PrintWriter(file);
out.println(orb.object_to_string(proxy));
out.flush();
file.close();
} catch (IOException ex) {
System.err.println("Can't write to `" + ex.getMessage() + "'");
System.exit(1);
}
orb.run();
File file = new File(refFile);
file.delete();
file = new File(refFileMgr);
file.delete();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
System.exit(0);
}
}
| 5,741 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestDSIRef_impl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
import org.omg.PortableServer.ServantLocatorPackage.*;
final class TestDSIRef_impl extends
org.omg.PortableServer.DynamicImplementation {
private ORB orb_;
private String name_;
private boolean compare_;
private boolean defaultServant_;
//
// From TestBase (no multiple inheritance)
//
public static void TEST(boolean expr) {
if (!expr)
throw new test.common.TestException();
}
TestDSIRef_impl(ORB orb, String name, boolean compare) {
orb_ = orb;
name_ = name;
compare_ = compare;
}
void setDefaultServant(boolean b) {
defaultServant_ = b;
}
//
// Standard IDL to Java Mapping
//
public void invoke(ServerRequest request) {
String name = request.operation();
if (!name.equals("aMethod")) {
NVList list = orb_.create_list(0);
request.arguments(list);
Any any = orb_.create_any();
BAD_OPERATIONHelper.insert(any, new BAD_OPERATION());
request.set_exception(any);
return;
}
//
// 8.3.1: "Unless it calls set_exception, the DIR must call arguments
// exactly once, even if the operation signature contains no
// parameters."
//
NVList list = orb_.create_list(0);
request.arguments(list);
org.omg.CORBA.Object currentObj = null;
try {
currentObj = orb_.resolve_initial_references("POACurrent");
} catch (UserException ex) {
}
org.omg.PortableServer.Current current = null;
if (currentObj != null)
current = org.omg.PortableServer.CurrentHelper.narrow(currentObj);
TEST(current != null);
byte[] oid = null;
try {
oid = current.get_object_id();
} catch (org.omg.PortableServer.CurrentPackage.NoContext ex) {
throw new RuntimeException();
}
String oidString = new String(oid);
if (compare_)
TEST(oidString.equals(name_));
org.omg.PortableServer.Servant servant = null;
try {
servant = current.get_servant();
} catch (org.omg.PortableServer.CurrentPackage.NoContext ex) {
throw new RuntimeException();
}
TEST(servant == this);
if (defaultServant_) {
POA poa = null;
try {
poa = current.get_POA();
} catch (org.omg.PortableServer.CurrentPackage.NoContext ex) {
throw new RuntimeException();
}
byte[] servantId = null;
try {
servantId = poa.servant_to_id(this);
} catch (ServantNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
TEST(servantId.length == oid.length);
TEST(servantId.equals(oid));
}
}
static final String[] interfaces_ = { "IDL:Test:1.0" };
public String[] _all_interfaces(POA poa, byte[] oid) {
return interfaces_;
}
}
| 5,742 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestDSI_impl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
class TestDSI_impl extends org.omg.PortableServer.DynamicImplementation {
//
// From TestBase (no multiple inheritance)
//
public static void TEST(boolean expr) {
if (!expr)
throw new test.common.TestException();
}
protected ORB orb_;
protected POA poa_;
protected org.omg.PortableServer.Current current_;
protected String name_;
protected boolean compare_;
TestDSI_impl(ORB orb, String name, boolean compare) {
org.omg.CORBA.Object currentObj = null;
try {
currentObj = orb.resolve_initial_references("POACurrent");
} catch (org.omg.CORBA.ORBPackage.InvalidName ex) {
}
TEST(currentObj != null);
current_ = org.omg.PortableServer.CurrentHelper.narrow(currentObj);
TEST(current_ != null);
}
TestDSI_impl(ORB orb, POA poa) {
orb_ = orb;
poa_ = poa;
name_ = "";
org.omg.CORBA.Object currentObj = null;
try {
currentObj = orb.resolve_initial_references("POACurrent");
} catch (org.omg.CORBA.ORBPackage.InvalidName ex) {
}
TEST(currentObj != null);
current_ = org.omg.PortableServer.CurrentHelper.narrow(currentObj);
TEST(current_ != null);
}
static final String[] interfaces_ = { "IDL:Test:1.0" };
public String[] _all_interfaces(POA poa, byte[] oid) {
return interfaces_;
}
public boolean _is_a(String id) {
if (id.equals("IDL:Test:1:0"))
return true;
return super._is_a(id);
}
public void invoke(ServerRequest request) {
String name = request.operation();
if (name.equals("aMethod")) {
NVList list = orb_.create_list(0);
request.arguments(list);
if (compare_) {
byte[] oid = null;
try {
oid = current_.get_object_id();
} catch (org.omg.PortableServer.CurrentPackage.NoContext ex) {
throw new RuntimeException();
}
String oidString = new String(oid);
TEST(oidString.equals(name_));
}
return;
}
System.err.println("DSI implementation: unknown operation: " + name);
NVList list = orb_.create_list(0);
request.arguments(list);
Any exAny = orb_.create_any();
BAD_OPERATIONHelper.insert(exAny, new org.omg.CORBA.BAD_OPERATION());
request.set_exception(exAny);
}
public POA _default_POA() {
if (poa_ != null)
return poa_;
return super._default_POA();
}
}
| 5,743 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestHelper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:Test:1.0
//
final public class TestHelper
{
public static void
insert(org.omg.CORBA.Any any, Test val)
{
any.insert_Object(val, type());
}
public static Test
extract(org.omg.CORBA.Any any)
{
if(any.type().equivalent(type()))
return narrow(any.extract_Object());
throw new org.omg.CORBA.BAD_OPERATION();
}
private static org.omg.CORBA.TypeCode typeCode_;
public static org.omg.CORBA.TypeCode
type()
{
if(typeCode_ == null)
{
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
typeCode_ = orb.create_interface_tc(id(), "Test");
}
return typeCode_;
}
public static String
id()
{
return "IDL:Test:1.0";
}
public static Test
read(org.omg.CORBA.portable.InputStream in)
{
org.omg.CORBA.Object _ob_v = in.read_Object();
try
{
return (Test)_ob_v;
}
catch(ClassCastException ex)
{
}
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)_ob_v;
_TestStub _ob_stub = new _TestStub();
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
public static void
write(org.omg.CORBA.portable.OutputStream out, Test val)
{
out.write_Object(val);
}
public static Test
narrow(org.omg.CORBA.Object val)
{
if(val != null)
{
try
{
return (Test)val;
}
catch(ClassCastException ex)
{
}
if(val._is_a(id()))
{
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_TestStub _ob_stub = new _TestStub();
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)val;
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
throw new org.omg.CORBA.BAD_PARAM();
}
return null;
}
public static Test
unchecked_narrow(org.omg.CORBA.Object val)
{
if(val != null)
{
try
{
return (Test)val;
}
catch(ClassCastException ex)
{
}
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_TestStub _ob_stub = new _TestStub();
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)val;
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
return null;
}
}
| 5,744 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestLocationForwardPOA.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestLocationForward:1.0
//
public abstract class TestLocationForwardPOA
extends org.omg.PortableServer.Servant
implements org.omg.CORBA.portable.InvokeHandler,
TestLocationForwardOperations
{
static final String[] _ob_ids_ =
{
"IDL:TestLocationForward:1.0",
"IDL:Test:1.0"
};
public TestLocationForward
_this()
{
return TestLocationForwardHelper.narrow(super._this_object());
}
public TestLocationForward
_this(org.omg.CORBA.ORB orb)
{
return TestLocationForwardHelper.narrow(super._this_object(orb));
}
public String[]
_all_interfaces(org.omg.PortableServer.POA poa, byte[] objectId)
{
return _ob_ids_;
}
public org.omg.CORBA.portable.OutputStream
_invoke(String opName,
org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
final String[] _ob_names =
{
"aMethod",
"deactivate_servant"
};
int _ob_left = 0;
int _ob_right = _ob_names.length;
int _ob_index = -1;
while(_ob_left < _ob_right)
{
int _ob_m = (_ob_left + _ob_right) / 2;
int _ob_res = _ob_names[_ob_m].compareTo(opName);
if(_ob_res == 0)
{
_ob_index = _ob_m;
break;
}
else if(_ob_res > 0)
_ob_right = _ob_m;
else
_ob_left = _ob_m + 1;
}
if(_ob_index == -1 && opName.charAt(0) == '_')
{
_ob_left = 0;
_ob_right = _ob_names.length;
String _ob_ami_op =
opName.substring(1);
while(_ob_left < _ob_right)
{
int _ob_m = (_ob_left + _ob_right) / 2;
int _ob_res = _ob_names[_ob_m].compareTo(_ob_ami_op);
if(_ob_res == 0)
{
_ob_index = _ob_m;
break;
}
else if(_ob_res > 0)
_ob_right = _ob_m;
else
_ob_left = _ob_m + 1;
}
}
switch(_ob_index)
{
case 0: // aMethod
return _OB_op_aMethod(in, handler);
case 1: // deactivate_servant
return _OB_op_deactivate_servant(in, handler);
}
throw new org.omg.CORBA.BAD_OPERATION();
}
private org.omg.CORBA.portable.OutputStream
_OB_op_aMethod(org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
org.omg.CORBA.portable.OutputStream out = null;
aMethod();
out = handler.createReply();
return out;
}
private org.omg.CORBA.portable.OutputStream
_OB_op_deactivate_servant(org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
org.omg.CORBA.portable.OutputStream out = null;
deactivate_servant();
out = handler.createReply();
return out;
}
}
| 5,745 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestLocationForwardHelper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestLocationForward:1.0
//
final public class TestLocationForwardHelper
{
public static void
insert(org.omg.CORBA.Any any, TestLocationForward val)
{
any.insert_Object(val, type());
}
public static TestLocationForward
extract(org.omg.CORBA.Any any)
{
if(any.type().equivalent(type()))
return narrow(any.extract_Object());
throw new org.omg.CORBA.BAD_OPERATION();
}
private static org.omg.CORBA.TypeCode typeCode_;
public static org.omg.CORBA.TypeCode
type()
{
if(typeCode_ == null)
{
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
typeCode_ = orb.create_interface_tc(id(), "TestLocationForward");
}
return typeCode_;
}
public static String
id()
{
return "IDL:TestLocationForward:1.0";
}
public static TestLocationForward
read(org.omg.CORBA.portable.InputStream in)
{
org.omg.CORBA.Object _ob_v = in.read_Object();
try
{
return (TestLocationForward)_ob_v;
}
catch(ClassCastException ex)
{
}
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)_ob_v;
_TestLocationForwardStub _ob_stub = new _TestLocationForwardStub();
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
public static void
write(org.omg.CORBA.portable.OutputStream out, TestLocationForward val)
{
out.write_Object(val);
}
public static TestLocationForward
narrow(org.omg.CORBA.Object val)
{
if(val != null)
{
try
{
return (TestLocationForward)val;
}
catch(ClassCastException ex)
{
}
if(val._is_a(id()))
{
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_TestLocationForwardStub _ob_stub = new _TestLocationForwardStub();
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)val;
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
throw new org.omg.CORBA.BAD_PARAM();
}
return null;
}
public static TestLocationForward
unchecked_narrow(org.omg.CORBA.Object val)
{
if(val != null)
{
try
{
return (TestLocationForward)val;
}
catch(ClassCastException ex)
{
}
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_TestLocationForwardStub _ob_stub = new _TestLocationForwardStub();
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)val;
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
return null;
}
}
| 5,746 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestServantLocatorServer.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
import org.omg.PortableServer.POAManagerPackage.*;
import org.omg.PortableServer.ServantLocatorPackage.*;
import java.io.*;
import java.util.Properties;
public final class TestServantLocatorServer extends test.common.TestBase {
final static class TestLocator_impl extends ServantLocatorPOA {
private ORB orb_;
Test_impl test_;
TestDSIRef_impl testDSI_;
TestLocator_impl(ORB orb) {
orb_ = orb;
test_ = new Test_impl(orb_, "test", false);
testDSI_ = new TestDSIRef_impl(orb_, "", false);
}
public Servant preinvoke(byte[] oid, POA poa, String operation,
CookieHolder the_cookie) throws ForwardRequest {
String oidString = new String(oid);
//
// If the user is requesting the object "test", "testDSI" or
// "testEx", then oblige
//
if (oidString.equals("test")) {
the_cookie.value = oidString;
return test_;
}
if (oidString.equals("testDSI")) {
the_cookie.value = oidString;
return testDSI_;
}
//
// Use test_ as the servant for testEx. We'll raise an
// exception in postinvoke().
//
if (oidString.equals("testEx")) {
the_cookie.value = oidString;
return test_;
}
//
// XXX test ForwardRequest
//
//
// Fail
//
throw new OBJECT_NOT_EXIST();
}
public void postinvoke(byte[] oid, POA poa, String operation,
java.lang.Object the_cookie, Servant the_servant) {
//
// Check the cookie
//
String oidString = new String(oid);
assertTrue(oidString.equals((String) the_cookie));
if (oidString.equals("testEx") && !operation.equals("_locate")) {
//
// The client must receive this exception as the result
// of an invocation on "testEx"
//
throw new org.omg.CORBA.NO_PERMISSION();
}
}
}
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
ORB orb = null;
try {
//
// Create ORB
//
orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
POAManager manager = root.the_POAManager();
Policy[] policies = new Policy[5];
policies[0] = root
.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[1] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
policies[2] = root
.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
policies[3] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.NON_RETAIN);
policies[4] = root
.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
POA persistentPOA = null;
try {
persistentPOA = root
.create_POA("persistent", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
TestLocator_impl locatorImpl = new TestLocator_impl(orb);
ServantLocator locator = locatorImpl._this(orb);
try {
persistentPOA.set_servant_manager(locator);
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
//
// Create four references, three good and one bad
//
byte[] oid1 = ("test").getBytes();
byte[] oid2 = ("testDSI").getBytes();
byte[] oid3 = ("testEx").getBytes();
byte[] oid4 = ("testBad").getBytes();
org.omg.CORBA.Object reference1 = persistentPOA
.create_reference_with_id(oid1, "IDL:Test:1.0");
org.omg.CORBA.Object reference2 = persistentPOA
.create_reference_with_id(oid2, "IDL:Test:1.0");
org.omg.CORBA.Object reference3 = persistentPOA
.create_reference_with_id(oid3, "IDL:Test:1.0");
org.omg.CORBA.Object reference4 = persistentPOA
.create_reference_with_id(oid4, "IDL:Test:1.0");
//
// Create server
//
TestInfo[] info = new TestInfo[4];
info[0] = new TestInfo();
info[1] = new TestInfo();
info[2] = new TestInfo();
info[3] = new TestInfo();
info[0].obj = TestHelper.narrow(reference1);
info[0].except_id = "";
info[1].obj = TestHelper.narrow(reference2);
info[1].except_id = "";
info[2].obj = TestHelper.narrow(reference3);
info[2].except_id = "IDL:omg.org/CORBA/NO_PERMISSION:1.0";
info[3].obj = TestHelper.narrow(reference4);
info[3].except_id = "IDL:omg.org/CORBA/OBJECT_NOT_EXIST:1.0";
TestServer_impl serverImpl = new TestServer_impl(orb, info);
TestServer server = serverImpl._this(orb);
//
// Save reference
//
String refFile = "Test.ref";
try {
FileOutputStream file = new FileOutputStream(refFile);
PrintWriter out = new PrintWriter(file);
out.println(orb.object_to_string(server));
out.flush();
file.close();
} catch (IOException ex) {
System.err.println("Can't write to `" + ex.getMessage() + "'");
System.exit(1);
}
//
// Run implementation
//
try {
manager.activate();
} catch (AdapterInactive ex) {
throw new RuntimeException();
}
orb.run();
File file = new File(refFile);
file.delete();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
System.exit(0);
}
}
| 5,747 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestInfoSeqHelper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestInfoSeq:1.0
//
final public class TestInfoSeqHelper
{
public static void
insert(org.omg.CORBA.Any any, TestInfo[] val)
{
org.omg.CORBA.portable.OutputStream out = any.create_output_stream();
write(out, val);
any.read_value(out.create_input_stream(), type());
}
public static TestInfo[]
extract(org.omg.CORBA.Any any)
{
if(any.type().equivalent(type()))
return read(any.create_input_stream());
else
throw new org.omg.CORBA.BAD_OPERATION();
}
private static org.omg.CORBA.TypeCode typeCode_;
public static org.omg.CORBA.TypeCode
type()
{
if(typeCode_ == null)
{
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
typeCode_ = orb.create_alias_tc(id(), "TestInfoSeq", orb.create_sequence_tc(0, TestInfoHelper.type()));
}
return typeCode_;
}
public static String
id()
{
return "IDL:TestInfoSeq:1.0";
}
public static TestInfo[]
read(org.omg.CORBA.portable.InputStream in)
{
TestInfo[] _ob_v;
int len0 = in.read_ulong();
_ob_v = new TestInfo[len0];
for(int i0 = 0; i0 < len0; i0++)
_ob_v[i0] = TestInfoHelper.read(in);
return _ob_v;
}
public static void
write(org.omg.CORBA.portable.OutputStream out, TestInfo[] val)
{
int len0 = val.length;
out.write_ulong(len0);
for(int i0 = 0; i0 < len0; i0++)
TestInfoHelper.write(out, val[i0]);
}
}
| 5,748 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestInfoSeqHolder.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestInfoSeq:1.0
//
final public class TestInfoSeqHolder implements org.omg.CORBA.portable.Streamable
{
public TestInfo[] value;
public
TestInfoSeqHolder()
{
}
public
TestInfoSeqHolder(TestInfo[] initial)
{
value = initial;
}
public void
_read(org.omg.CORBA.portable.InputStream in)
{
value = TestInfoSeqHelper.read(in);
}
public void
_write(org.omg.CORBA.portable.OutputStream out)
{
TestInfoSeqHelper.write(out, value);
}
public org.omg.CORBA.TypeCode
_type()
{
return TestInfoSeqHelper.type();
}
}
| 5,749 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestLocationForwardHolder.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestLocationForward:1.0
//
final public class TestLocationForwardHolder implements org.omg.CORBA.portable.Streamable
{
public TestLocationForward value;
public
TestLocationForwardHolder()
{
}
public
TestLocationForwardHolder(TestLocationForward initial)
{
value = initial;
}
public void
_read(org.omg.CORBA.portable.InputStream in)
{
value = TestLocationForwardHelper.read(in);
}
public void
_write(org.omg.CORBA.portable.OutputStream out)
{
TestLocationForwardHelper.write(out, value);
}
public org.omg.CORBA.TypeCode
_type()
{
return TestLocationForwardHelper.type();
}
}
| 5,750 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestHolder.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:Test:1.0
//
final public class TestHolder implements org.omg.CORBA.portable.Streamable
{
public Test value;
public
TestHolder()
{
}
public
TestHolder(Test initial)
{
value = initial;
}
public void
_read(org.omg.CORBA.portable.InputStream in)
{
value = TestHelper.read(in);
}
public void
_write(org.omg.CORBA.portable.OutputStream out)
{
TestHelper.write(out, value);
}
public org.omg.CORBA.TypeCode
_type()
{
return TestHelper.type();
}
}
| 5,751 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/_POAManagerProxyStub.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:POAManagerProxy:1.0
//
public class _POAManagerProxyStub extends org.omg.CORBA.portable.ObjectImpl
implements POAManagerProxy
{
private static final String[] _ob_ids_ =
{
"IDL:POAManagerProxy:1.0",
};
public String[]
_ids()
{
return _ob_ids_;
}
final public static java.lang.Class _ob_opsClass = POAManagerProxyOperations.class;
//
// IDL:POAManagerProxy/activate:1.0
//
public void
activate()
throws test.poa.POAManagerProxyPackage.AdapterInactive
{
while(true)
{
if(!this._is_local())
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.portable.InputStream in = null;
try
{
out = _request("activate", true);
in = _invoke(out);
return;
}
catch(org.omg.CORBA.portable.RemarshalException _ob_ex)
{
continue;
}
catch(org.omg.CORBA.portable.ApplicationException _ob_aex)
{
final String _ob_id = _ob_aex.getId();
in = _ob_aex.getInputStream();
if(_ob_id.equals(test.poa.POAManagerProxyPackage.AdapterInactiveHelper.id()))
throw test.poa.POAManagerProxyPackage.AdapterInactiveHelper.read(in);
throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: " + _ob_id);
}
finally
{
_releaseReply(in);
}
}
else
{
org.omg.CORBA.portable.ServantObject _ob_so = _servant_preinvoke("activate", _ob_opsClass);
if(_ob_so == null)
continue;
POAManagerProxyOperations _ob_self = (POAManagerProxyOperations)_ob_so.servant;
try
{
_ob_self.activate();
return;
}
finally
{
_servant_postinvoke(_ob_so);
}
}
}
}
//
// IDL:POAManagerProxy/hold_requests:1.0
//
public void
hold_requests(boolean _ob_a0)
throws test.poa.POAManagerProxyPackage.AdapterInactive
{
while(true)
{
if(!this._is_local())
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.portable.InputStream in = null;
try
{
out = _request("hold_requests", true);
out.write_boolean(_ob_a0);
in = _invoke(out);
return;
}
catch(org.omg.CORBA.portable.RemarshalException _ob_ex)
{
continue;
}
catch(org.omg.CORBA.portable.ApplicationException _ob_aex)
{
final String _ob_id = _ob_aex.getId();
in = _ob_aex.getInputStream();
if(_ob_id.equals(test.poa.POAManagerProxyPackage.AdapterInactiveHelper.id()))
throw test.poa.POAManagerProxyPackage.AdapterInactiveHelper.read(in);
throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: " + _ob_id);
}
finally
{
_releaseReply(in);
}
}
else
{
org.omg.CORBA.portable.ServantObject _ob_so = _servant_preinvoke("hold_requests", _ob_opsClass);
if(_ob_so == null)
continue;
POAManagerProxyOperations _ob_self = (POAManagerProxyOperations)_ob_so.servant;
try
{
_ob_self.hold_requests(_ob_a0);
return;
}
finally
{
_servant_postinvoke(_ob_so);
}
}
}
}
//
// IDL:POAManagerProxy/discard_requests:1.0
//
public void
discard_requests(boolean _ob_a0)
throws test.poa.POAManagerProxyPackage.AdapterInactive
{
while(true)
{
if(!this._is_local())
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.portable.InputStream in = null;
try
{
out = _request("discard_requests", true);
out.write_boolean(_ob_a0);
in = _invoke(out);
return;
}
catch(org.omg.CORBA.portable.RemarshalException _ob_ex)
{
continue;
}
catch(org.omg.CORBA.portable.ApplicationException _ob_aex)
{
final String _ob_id = _ob_aex.getId();
in = _ob_aex.getInputStream();
if(_ob_id.equals(test.poa.POAManagerProxyPackage.AdapterInactiveHelper.id()))
throw test.poa.POAManagerProxyPackage.AdapterInactiveHelper.read(in);
throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: " + _ob_id);
}
finally
{
_releaseReply(in);
}
}
else
{
org.omg.CORBA.portable.ServantObject _ob_so = _servant_preinvoke("discard_requests", _ob_opsClass);
if(_ob_so == null)
continue;
POAManagerProxyOperations _ob_self = (POAManagerProxyOperations)_ob_so.servant;
try
{
_ob_self.discard_requests(_ob_a0);
return;
}
finally
{
_servant_postinvoke(_ob_so);
}
}
}
}
//
// IDL:POAManagerProxy/deactivate:1.0
//
public void
deactivate(boolean _ob_a0,
boolean _ob_a1)
throws test.poa.POAManagerProxyPackage.AdapterInactive
{
while(true)
{
if(!this._is_local())
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.portable.InputStream in = null;
try
{
out = _request("deactivate", true);
out.write_boolean(_ob_a0);
out.write_boolean(_ob_a1);
in = _invoke(out);
return;
}
catch(org.omg.CORBA.portable.RemarshalException _ob_ex)
{
continue;
}
catch(org.omg.CORBA.portable.ApplicationException _ob_aex)
{
final String _ob_id = _ob_aex.getId();
in = _ob_aex.getInputStream();
if(_ob_id.equals(test.poa.POAManagerProxyPackage.AdapterInactiveHelper.id()))
throw test.poa.POAManagerProxyPackage.AdapterInactiveHelper.read(in);
throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: " + _ob_id);
}
finally
{
_releaseReply(in);
}
}
else
{
org.omg.CORBA.portable.ServantObject _ob_so = _servant_preinvoke("deactivate", _ob_opsClass);
if(_ob_so == null)
continue;
POAManagerProxyOperations _ob_self = (POAManagerProxyOperations)_ob_so.servant;
try
{
_ob_self.deactivate(_ob_a0, _ob_a1);
return;
}
finally
{
_servant_postinvoke(_ob_so);
}
}
}
}
//
// IDL:POAManagerProxy/get_state:1.0
//
public test.poa.POAManagerProxyPackage.State
get_state()
{
while(true)
{
if(!this._is_local())
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.portable.InputStream in = null;
try
{
out = _request("get_state", true);
in = _invoke(out);
test.poa.POAManagerProxyPackage.State _ob_r = test.poa.POAManagerProxyPackage.StateHelper.read(in);
return _ob_r;
}
catch(org.omg.CORBA.portable.RemarshalException _ob_ex)
{
continue;
}
catch(org.omg.CORBA.portable.ApplicationException _ob_aex)
{
final String _ob_id = _ob_aex.getId();
in = _ob_aex.getInputStream();
throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: " + _ob_id);
}
finally
{
_releaseReply(in);
}
}
else
{
org.omg.CORBA.portable.ServantObject _ob_so = _servant_preinvoke("get_state", _ob_opsClass);
if(_ob_so == null)
continue;
POAManagerProxyOperations _ob_self = (POAManagerProxyOperations)_ob_so.servant;
try
{
return _ob_self.get_state();
}
finally
{
_servant_postinvoke(_ob_so);
}
}
}
}
}
| 5,752 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestLocationForwardClient.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
import java.util.*;
final public class TestLocationForwardClient extends test.common.TestBase {
public static void main(String args[]) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
ORB orb = null;
try {
//
// Create ORB
//
orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
POA poa;
Policy[] policies;
POAManager manager = root.the_POAManager();
//
// Create POA
//
policies = new Policy[4];
policies[0] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
policies[1] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
policies[2] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[3] = root
.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
try {
poa = root.create_POA("poa", manager, policies);
} catch (InvalidPolicy ex) {
throw new RuntimeException();
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
}
TestLocationForwardActivator_impl activatorImpl = new TestLocationForwardActivator_impl();
ServantActivator activator = activatorImpl._this(orb);
try {
poa.set_servant_manager(activator);
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
byte[] oid = ("test").getBytes();
org.omg.CORBA.Object reference = poa.create_reference_with_id(oid,
"IDL:Test:1.0");
//
// Read all object references from file
//
org.omg.CORBA.Object obj = orb
.string_to_object("relfile:///Test.ref");
if (obj == null) {
System.err.println("TestLocationForwardClient: "
+ "cannot read IOR from Test.ref");
System.exit(1);
}
TestLocationForwardServer server = TestLocationForwardServerHelper
.narrow(obj);
assertTrue(server != null);
org.omg.CORBA.Object servant = server.get_servant();
activatorImpl.setForwardRequest(servant);
TestLocationForward_impl testImpl = new TestLocationForward_impl(
orb);
activatorImpl.setActivatedServant(testImpl);
try {
manager.activate();
} catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
throw new RuntimeException();
}
server.setForwardRequest(reference);
//
// Run some calls
//
TestLocationForward local = TestLocationForwardHelper
.narrow(reference);
//
// First should be local
//
local.aMethod();
local.deactivate_servant();
//
// Second, should be remote
//
local.aMethod();
local.deactivate_servant();
//
// Third should be local again
//
local.aMethod();
local.deactivate_servant();
//
// Clean up
//
poa.destroy(true, true);
server.deactivate();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
System.exit(0);
}
}
| 5,753 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestLocationForward_impl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
final class TestLocationForward_impl extends TestLocationForwardPOA {
private Test_impl delegate_;
TestLocationForward_impl(ORB orb) {
delegate_ = new Test_impl(orb, "", false);
}
public void deactivate_servant() {
byte[] oid = null;
POA poa = null;
try {
oid = delegate_.current_.get_object_id();
poa = delegate_.current_.get_POA();
} catch (org.omg.PortableServer.CurrentPackage.NoContext ex) {
throw new RuntimeException();
}
try {
poa.deactivate_object(oid);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ObjectNotActive ex) {
throw new RuntimeException();
}
}
public void aMethod() {
delegate_.aMethod();
}
}
| 5,754 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestDeactivate.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
public final class TestDeactivate extends test.common.TestBase {
final static class Test_impl2 extends TestPOA {
private POA poa_;
private boolean called_ = false;
private boolean finished_ = false;
Test_impl2(POA poa) {
poa_ = poa;
}
synchronized public void aMethod() {
called_ = true;
notify();
try {
wait(1000);
} catch (InterruptedException ex) {
}
finished_ = true;
}
public POA _default_POA() {
return poa_;
}
synchronized void blockUntilCalled() {
while (!called_) {
try {
wait();
} catch (InterruptedException ex) {
}
}
}
synchronized boolean callComplete() {
return finished_;
}
}
final static class LongCaller extends Thread {
private Test t_;
LongCaller(Test t) {
t_ = t;
}
public void run() {
try {
t_.aMethod();
} catch (SystemException ex) {
ex.printStackTrace();
}
}
}
//
// In this test we want to spawn a thread to call a method on the Test
// interface. This method call should take some time. While the thread
// is calling the method we attempt to deactivate the object. This
// should not complete for some time, since it should wait for all
// outstanding method calls to complete.
//
static void TestDeactivateThreaded(ORB orb, POA root) {
Test_impl2 impl = new Test_impl2(root);
Test t = impl._this(orb);
byte[] oid = null;
try {
oid = root.servant_to_id(impl);
} catch (ServantNotActive ex) {
assertTrue(false);
} catch (WrongPolicy ex) {
assertTrue(false);
}
Thread thr = new LongCaller(t);
thr.start();
impl.blockUntilCalled();
//
// Test: deactivate_object while method call is active
//
try {
root.deactivate_object(oid);
} catch (ObjectNotActive ex) {
assertTrue(false);
} catch (WrongPolicy ex) {
assertTrue(false);
}
//
// Once we've deactivated the object the re-activation shouldn't
// complete until the method call completes
//
try {
root.activate_object_with_id(oid, impl);
} catch (ObjectAlreadyActive ex) {
assertTrue(false);
} catch (ServantAlreadyActive ex) {
assertTrue(false);
} catch (WrongPolicy ex) {
assertTrue(false);
}
//
// The destroy call shouldn't return until the aMethod call is
// complete
//
assertTrue(impl.callComplete());
//
// Wait for the thread to terminate
//
while (thr.isAlive()) {
try {
thr.join();
} catch (InterruptedException ex) {
}
}
try {
root.deactivate_object(oid);
} catch (ObjectNotActive ex) {
assertTrue(false);
} catch (WrongPolicy ex) {
assertTrue(false);
}
}
static void TestDeactivateBlocking(ORB orb, POA root) {
Test_impl impl = new Test_impl(orb, "", false);
Test t = impl._this(orb);
t.aMethod();
byte[] oid = null;
try {
oid = root.servant_to_id(impl);
} catch (ServantNotActive ex) {
assertTrue(false);
} catch (WrongPolicy ex) {
assertTrue(false);
}
try {
root.deactivate_object(oid);
} catch (ObjectNotActive ex) {
assertTrue(false);
} catch (WrongPolicy ex) {
assertTrue(false);
}
try {
t.aMethod();
assertTrue(false); // expected OBJECT_NOT_EXIST
} catch (OBJECT_NOT_EXIST ex) {
// Expected
}
}
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
int status = 0;
ORB orb = null;
try {
//
// Create ORB
//
orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
//
// Activate the RootPOA manager
//
POAManager rootMgr = root.the_POAManager();
assertTrue(rootMgr != null);
try {
rootMgr.activate();
} catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
assertTrue(false);
}
System.out.print("Testing deactivate... ");
System.out.flush();
//
// Run the tests using the root POA
//
TestDeactivateBlocking(orb, root);
TestDeactivateThreaded(orb, root);
System.out.println("Done!");
} catch (SystemException ex) {
ex.printStackTrace();
status = 1;
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
status = 1;
}
}
System.exit(status);
}
}
| 5,755 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestActivate.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
public final class TestActivate extends test.common.TestBase {
final static class TestActivator_impl extends ServantActivatorPOA {
private byte[] oid_;
private POA poa_;
private Servant servant_;
private boolean remaining_;
private boolean valid_;
void expect(byte[] oid, POA poa, Servant servant, boolean remaining) {
oid_ = oid;
poa_ = poa;
servant_ = servant;
remaining_ = remaining;
valid_ = false;
}
boolean isValid() {
return valid_;
}
public Servant incarnate(byte[] oid, POA poa) throws ForwardRequest {
return null;
}
public void etherealize(byte[] oid, POA poa, Servant servant,
boolean cleanup, boolean remaining) {
assertTrue(TestUtil.Compare(oid_, oid));
assertTrue(poa_._is_equivalent(poa));
assertTrue(servant_ == servant);
assertTrue(remaining_ == remaining);
valid_ = true;
}
}
private static void run(ORB orb, POA root) {
org.omg.CORBA.Object obj;
POA system, nonretain, multiple, ether;
byte[] id1, id2, id3;
Policy[] policies;
Test_impl servant1;
Test_impl servant2;
Servant tmpserv;
POAManager manager = root.the_POAManager();
try {
manager.activate();
} catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
throw new RuntimeException();
}
//
// Create POAs
//
policies = new Policy[3];
policies[0] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.SYSTEM_ID);
policies[1] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
policies[2] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
try {
system = root.create_POA("system_id", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
policies = new Policy[5];
policies[0] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
policies[1] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
policies[2] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.NON_RETAIN);
policies[3] = root
.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_DEFAULT_SERVANT);
policies[4] = root
.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
try {
nonretain = root.create_POA("nonretain", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
policies = new Policy[3];
policies[0] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.SYSTEM_ID);
policies[1] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
policies[2] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
try {
multiple = root.create_POA("multiple_id", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
policies = new Policy[3];
policies[0] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.SYSTEM_ID);
policies[1] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
policies[2] = root
.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
try {
ether = root.create_POA("ether", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
TestActivator_impl activatorImpl = new TestActivator_impl();
ServantActivator activator = activatorImpl._this(orb);
//
// Start tests
//
//
// Test: set_servant_manager with nil argument
//
try {
ether.set_servant_manager(null);
assertTrue(false); // set_servant_manager should not have succeeded
} catch (OBJ_ADAPTER ex) {
// expected
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
try {
ether.set_servant_manager(activator);
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
servant1 = new Test_impl(orb, "obj1", false);
servant2 = new Test_impl(orb, "obj2", false);
//
// Test: activate_object w/ SYSTEM_ID POA
//
try {
id1 = system.activate_object(servant1);
id2 = system.activate_object(servant2);
} catch (ServantAlreadyActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(!TestUtil.Compare(id1, id2));
try {
tmpserv = system.id_to_servant(id1);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(tmpserv == servant1);
try {
tmpserv = system.id_to_servant(id2);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(tmpserv == servant2);
//
// Test: ServantAlreadyActive exception
//
try {
system.activate_object(servant1);
assertTrue(false); // activate_object should not have succeeded
} catch (ServantAlreadyActive ex) {
// expected
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
try {
system.activate_object(servant2);
assertTrue(false); // activate_object should not have succeeded
} catch (ServantAlreadyActive ex) {
// expected
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
//
// Test: deactivate_object
//
try {
system.deactivate_object(id2);
system.deactivate_object(id1);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
//
// Test: ObjectNotActive exception
//
try {
system.deactivate_object(id1);
assertTrue(false); // deactivate_object should not have succeeded
} catch (ObjectNotActive ex) {
// expected
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
try {
system.deactivate_object(id2);
assertTrue(false); // deactivate_object should not have succeeded
} catch (ObjectNotActive ex) {
// expected
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
//
// Test: WrongPolicy exception
//
try {
nonretain.activate_object(servant1);
assertTrue(false); // activate_object should not have succeeded
} catch (WrongPolicy ex) {
// expected
} catch (ServantAlreadyActive ex) {
throw new RuntimeException();
}
try {
byte[] id = ("XXX").getBytes();
nonretain.activate_object_with_id(id, servant1);
assertTrue(false); // activate_object_with_id should not have succeeded
} catch (WrongPolicy ex) {
// expected
} catch (ServantAlreadyActive ex) {
throw new RuntimeException();
} catch (ObjectAlreadyActive ex) {
throw new RuntimeException();
}
try {
byte[] id = ("XXX").getBytes();
nonretain.deactivate_object(id);
assertTrue(false); // deactivate_object should not have succeeded
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
// expected
}
//
// Test: activate_object w/ MULTIPLE_ID POA
//
try {
id1 = multiple.activate_object(servant1);
id2 = multiple.activate_object(servant1);
} catch (ServantAlreadyActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(!TestUtil.Compare(id1, id2));
try {
tmpserv = multiple.id_to_servant(id1);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(tmpserv == servant1);
try {
tmpserv = multiple.id_to_servant(id2);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(tmpserv == servant1);
//
// Test: confirm servant1 is no longer active
//
try {
multiple.deactivate_object(id1);
multiple.deactivate_object(id2);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
try {
multiple.id_to_servant(id1);
} catch (ObjectNotActive ex) {
// expected
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
try {
multiple.id_to_servant(id2);
} catch (ObjectNotActive ex) {
// expected
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
//
// Test: confirm ServantActivator::etherealize is invoked on
// deactivate
//
try {
id1 = ether.activate_object(servant1);
id2 = ether.activate_object(servant1);
id3 = ether.activate_object(servant2);
} catch (ServantAlreadyActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
activatorImpl.expect(id1, ether, servant1, true);
try {
ether.deactivate_object(id1);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(activatorImpl.isValid());
activatorImpl.expect(id2, ether, servant1, false);
try {
ether.deactivate_object(id2);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(activatorImpl.isValid());
activatorImpl.expect(id3, ether, servant2, false);
try {
ether.deactivate_object(id3);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(activatorImpl.isValid());
system.destroy(true, true);
nonretain.destroy(true, true);
multiple.destroy(true, true);
ether.destroy(true, true);
//
// Since activatorImpl is a stack-based servant, we need to deactivate
// it before it goes out of scope
//
byte[] id = null;
try {
id = root.servant_to_id(activatorImpl);
} catch (ServantNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
try {
root.deactivate_object(id);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
tmpserv = null;
servant1 = null;
servant2 = null;
}
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
int status = 0;
ORB orb = null;
try {
//
// Create ORB
//
orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
//
// Run the test
//
System.out.print("Testing servant activator... ");
System.out.flush();
run(orb, root);
System.out.println("Done!");
} catch (SystemException ex) {
ex.printStackTrace();
status = 1;
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
status = 1;
}
}
System.exit(status);
}
}
| 5,756 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestLocationForwardServerPOA.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestLocationForwardServer:1.0
//
public abstract class TestLocationForwardServerPOA
extends org.omg.PortableServer.Servant
implements org.omg.CORBA.portable.InvokeHandler,
TestLocationForwardServerOperations
{
static final String[] _ob_ids_ =
{
"IDL:TestLocationForwardServer:1.0",
};
public TestLocationForwardServer
_this()
{
return TestLocationForwardServerHelper.narrow(super._this_object());
}
public TestLocationForwardServer
_this(org.omg.CORBA.ORB orb)
{
return TestLocationForwardServerHelper.narrow(super._this_object(orb));
}
public String[]
_all_interfaces(org.omg.PortableServer.POA poa, byte[] objectId)
{
return _ob_ids_;
}
public org.omg.CORBA.portable.OutputStream
_invoke(String opName,
org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
final String[] _ob_names =
{
"deactivate",
"get_servant",
"setForwardRequest"
};
int _ob_left = 0;
int _ob_right = _ob_names.length;
int _ob_index = -1;
while(_ob_left < _ob_right)
{
int _ob_m = (_ob_left + _ob_right) / 2;
int _ob_res = _ob_names[_ob_m].compareTo(opName);
if(_ob_res == 0)
{
_ob_index = _ob_m;
break;
}
else if(_ob_res > 0)
_ob_right = _ob_m;
else
_ob_left = _ob_m + 1;
}
if(_ob_index == -1 && opName.charAt(0) == '_')
{
_ob_left = 0;
_ob_right = _ob_names.length;
String _ob_ami_op =
opName.substring(1);
while(_ob_left < _ob_right)
{
int _ob_m = (_ob_left + _ob_right) / 2;
int _ob_res = _ob_names[_ob_m].compareTo(_ob_ami_op);
if(_ob_res == 0)
{
_ob_index = _ob_m;
break;
}
else if(_ob_res > 0)
_ob_right = _ob_m;
else
_ob_left = _ob_m + 1;
}
}
switch(_ob_index)
{
case 0: // deactivate
return _OB_op_deactivate(in, handler);
case 1: // get_servant
return _OB_op_get_servant(in, handler);
case 2: // setForwardRequest
return _OB_op_setForwardRequest(in, handler);
}
throw new org.omg.CORBA.BAD_OPERATION();
}
private org.omg.CORBA.portable.OutputStream
_OB_op_deactivate(org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
org.omg.CORBA.portable.OutputStream out = null;
deactivate();
out = handler.createReply();
return out;
}
private org.omg.CORBA.portable.OutputStream
_OB_op_get_servant(org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.Object _ob_r = get_servant();
out = handler.createReply();
out.write_Object(_ob_r);
return out;
}
private org.omg.CORBA.portable.OutputStream
_OB_op_setForwardRequest(org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.Object _ob_a0 = in.read_Object();
setForwardRequest(_ob_a0);
out = handler.createReply();
return out;
}
}
| 5,757 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestClient.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
import org.omg.CORBA.*;
public class TestClient extends test.common.TestBase {
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
ORB orb = null;
try {
//
// Create ORB
//
orb = ORB.init(args, props);
//
// Get server
//
org.omg.CORBA.Object obj = orb
.string_to_object("relfile:/Test.ref");
if (obj == null) {
System.err.println("Can't read from Test.ref");
System.exit(1);
}
TestServer server = TestServerHelper.narrow(obj);
assertTrue(server != null);
TestInfo[] info = server.get_info();
for (int i = 0; i < info.length; i++) {
try {
info[i].obj.aMethod();
assertTrue(info[i].except_id.length() == 0);
} catch (SystemException ex) {
String id = org.apache.yoko.orb.OB.Util.getExceptionId(ex);
if (!id.equals(info[i].except_id)) {
System.err.println("TestClient: Invocation on "
+ "object #" + i + " raised an "
+ "unexpected exception");
System.err.println("Expected " + info[i].except_id
+ " but caught " + id);
assertTrue(false);
}
}
}
server.deactivate();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
System.exit(0);
}
}
| 5,758 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestLocationForwardServerMain.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
import org.omg.PortableServer.POAManagerPackage.*;
import java.io.*;
public final class TestLocationForwardServerMain {
final static class Server_impl extends TestLocationForwardServerPOA {
private ORB orb_;
private TestLocationForwardActivator_impl activator_;
private org.omg.CORBA.Object servant_;
Server_impl(ORB orb, TestLocationForwardActivator_impl activator,
org.omg.CORBA.Object servant) {
orb_ = orb;
activator_ = activator;
servant_ = servant;
}
public void setForwardRequest(org.omg.CORBA.Object obj) {
activator_.setForwardRequest(obj);
}
public org.omg.CORBA.Object get_servant() {
return servant_;
}
public void deactivate() {
orb_.shutdown(false);
}
}
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
ORB orb = null;
try {
//
// Create ORB
//
orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
POA poa;
Policy[] policies;
POAManager manager = root.the_POAManager();
//
// Create POAs
//
policies = new Policy[4];
policies[0] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
policies[1] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
policies[2] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[3] = root
.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
try {
poa = root.create_POA("poa", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
TestLocationForwardActivator_impl activatorImpl = new TestLocationForwardActivator_impl();
org.omg.PortableServer.ServantActivator activator = activatorImpl
._this(orb);
try {
poa.set_servant_manager(activator);
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
byte[] oid = "test".getBytes();
org.omg.CORBA.Object obj = poa.create_reference_with_id(oid,
"IDL:Test:1.0");
TestLocationForward_impl testImpl = new TestLocationForward_impl(
orb);
activatorImpl.setActivatedServant(testImpl);
Server_impl serverImpl = new Server_impl(orb, activatorImpl, obj);
TestLocationForwardServer server = serverImpl._this(orb);
//
// Save reference
//
String refFile = "Test.ref";
try {
FileOutputStream file = new FileOutputStream(refFile);
PrintWriter out = new PrintWriter(file);
out.println(orb.object_to_string(server));
out.flush();
file.close();
} catch (IOException ex) {
System.err.println("Can't write to `" + ex.getMessage() + "'");
System.exit(1);
}
//
// Run implementation
//
try {
manager.activate();
} catch (AdapterInactive ex) {
throw new RuntimeException();
}
orb.run();
File file = new File(refFile);
file.delete();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
System.exit(0);
}
}
| 5,759 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/PMSTestThread.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import java.util.concurrent.CountDownLatch;
final class PMSTestThread extends Thread {
private final Test test_;
private final CountDownLatch startLatch = new CountDownLatch(1);
public volatile Result result = null;
public enum Result { SUCCESS, FAILURE, ERROR };
public void run() {
startLatch.countDown();
try {
test_.aMethod();
result = Result.SUCCESS;
} catch (org.omg.CORBA.TRANSIENT ex) {
result = Result.FAILURE;
return;
} catch (org.omg.CORBA.SystemException ex) {
result = Result.ERROR;
System.err.println("Unexpected: " + ex);
}
}
public void waitForStart() {
do {
try {
startLatch.await();
return;
} catch (InterruptedException ie) {}
} while (true);
}
public void waitForEnd() {
while (isAlive()) {
try {
join();
} catch (InterruptedException ie) {}
}
}
PMSTestThread(Test test) {
test_ = test;
}
}
| 5,760 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/Test_impl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
final class Test_impl extends TestPOA {
//
// From TestBase (no multiple inheritance)
//
public static void TEST(boolean expr) {
if (!expr)
throw new test.common.TestException();
}
private POA poa_;
org.omg.PortableServer.Current current_;
private String name_;
private boolean compare_;
Test_impl(ORB orb, String name, boolean compare) {
name_ = name;
compare_ = compare;
org.omg.CORBA.Object currentObj = null;
try {
currentObj = orb.resolve_initial_references("POACurrent");
} catch (org.omg.CORBA.ORBPackage.InvalidName ex) {
}
TEST(currentObj != null);
current_ = org.omg.PortableServer.CurrentHelper.narrow(currentObj);
TEST(current_ != null);
}
Test_impl(ORB orb, POA poa) {
poa_ = poa;
name_ = "";
compare_ = false;
org.omg.CORBA.Object currentObj = null;
try {
currentObj = orb.resolve_initial_references("POACurrent");
} catch (org.omg.CORBA.ORBPackage.InvalidName ex) {
}
TEST(currentObj != null);
current_ = org.omg.PortableServer.CurrentHelper.narrow(currentObj);
TEST(current_ != null);
}
public void aMethod() {
if (compare_) {
byte[] oid = null;
try {
oid = current_.get_object_id();
} catch (org.omg.PortableServer.CurrentPackage.NoContext ex) {
throw new RuntimeException();
}
String oidString = new String(oid);
TEST(oidString.equals(name_));
}
}
public POA _default_POA() {
if (poa_ != null)
return poa_;
return super._default_POA();
}
}
| 5,761 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestDispatchStrategyClient.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import java.util.*;
final public class TestDispatchStrategyClient extends test.common.TestBase {
public static void main(String args[]) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
org.omg.CORBA.ORB orb = null;
try {
//
// Create ORB
//
orb = org.omg.CORBA.ORB.init(args, props);
//
// Get test server object reference
//
org.omg.CORBA.Object obj = orb
.string_to_object("relfile:/Test.ref");
if (obj == null) {
System.err.println("TestDispatchStrategyClient: "
+ "cannot read IOR from Test.ref");
System.exit(1);
}
TestServer server = TestServerHelper.narrow(obj);
TestInfo[] info = server.get_info();
//
// Test the thread dispatch strategies by calling
// methods on each returned object reference
//
org.omg.CORBA.Request req;
int idx;
for (idx = 0; idx < info.length; idx++) {
assertTrue(info[idx].obj != null);
for (int idx2 = 0; idx2 < 4; idx2++) {
req = info[idx].obj._request("aMethod");
req.send_deferred();
}
}
idx = info.length * 4;
do {
req = orb.get_next_response();
} while (--idx != 0);
server.deactivate();
} catch (org.omg.CORBA.SystemException ex) {
ex.printStackTrace();
System.exit(1);
} catch (org.omg.CORBA.UserException ex) {
ex.printStackTrace();
System.exit(1);
}
if (orb != null) {
try {
orb.destroy();
} catch (org.omg.CORBA.SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
System.exit(0);
}
}
| 5,762 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/_TestLocationForwardServerStub.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestLocationForwardServer:1.0
//
public class _TestLocationForwardServerStub extends org.omg.CORBA.portable.ObjectImpl
implements TestLocationForwardServer
{
private static final String[] _ob_ids_ =
{
"IDL:TestLocationForwardServer:1.0",
};
public String[]
_ids()
{
return _ob_ids_;
}
final public static java.lang.Class _ob_opsClass = TestLocationForwardServerOperations.class;
//
// IDL:TestLocationForwardServer/setForwardRequest:1.0
//
public void
setForwardRequest(org.omg.CORBA.Object _ob_a0)
{
while(true)
{
if(!this._is_local())
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.portable.InputStream in = null;
try
{
out = _request("setForwardRequest", true);
out.write_Object(_ob_a0);
in = _invoke(out);
return;
}
catch(org.omg.CORBA.portable.RemarshalException _ob_ex)
{
continue;
}
catch(org.omg.CORBA.portable.ApplicationException _ob_aex)
{
final String _ob_id = _ob_aex.getId();
in = _ob_aex.getInputStream();
throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: " + _ob_id);
}
finally
{
_releaseReply(in);
}
}
else
{
org.omg.CORBA.portable.ServantObject _ob_so = _servant_preinvoke("setForwardRequest", _ob_opsClass);
if(_ob_so == null)
continue;
TestLocationForwardServerOperations _ob_self = (TestLocationForwardServerOperations)_ob_so.servant;
try
{
_ob_self.setForwardRequest(_ob_a0);
return;
}
finally
{
_servant_postinvoke(_ob_so);
}
}
}
}
//
// IDL:TestLocationForwardServer/get_servant:1.0
//
public org.omg.CORBA.Object
get_servant()
{
while(true)
{
if(!this._is_local())
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.portable.InputStream in = null;
try
{
out = _request("get_servant", true);
in = _invoke(out);
org.omg.CORBA.Object _ob_r = in.read_Object();
return _ob_r;
}
catch(org.omg.CORBA.portable.RemarshalException _ob_ex)
{
continue;
}
catch(org.omg.CORBA.portable.ApplicationException _ob_aex)
{
final String _ob_id = _ob_aex.getId();
in = _ob_aex.getInputStream();
throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: " + _ob_id);
}
finally
{
_releaseReply(in);
}
}
else
{
org.omg.CORBA.portable.ServantObject _ob_so = _servant_preinvoke("get_servant", _ob_opsClass);
if(_ob_so == null)
continue;
TestLocationForwardServerOperations _ob_self = (TestLocationForwardServerOperations)_ob_so.servant;
try
{
return _ob_self.get_servant();
}
finally
{
_servant_postinvoke(_ob_so);
}
}
}
}
//
// IDL:TestLocationForwardServer/deactivate:1.0
//
public void
deactivate()
{
while(true)
{
if(!this._is_local())
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.portable.InputStream in = null;
try
{
out = _request("deactivate", true);
in = _invoke(out);
return;
}
catch(org.omg.CORBA.portable.RemarshalException _ob_ex)
{
continue;
}
catch(org.omg.CORBA.portable.ApplicationException _ob_aex)
{
final String _ob_id = _ob_aex.getId();
in = _ob_aex.getInputStream();
throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: " + _ob_id);
}
finally
{
_releaseReply(in);
}
}
else
{
org.omg.CORBA.portable.ServantObject _ob_so = _servant_preinvoke("deactivate", _ob_opsClass);
if(_ob_so == null)
continue;
TestLocationForwardServerOperations _ob_self = (TestLocationForwardServerOperations)_ob_so.servant;
try
{
_ob_self.deactivate();
return;
}
finally
{
_servant_postinvoke(_ob_so);
}
}
}
}
}
| 5,763 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestPOA.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:Test:1.0
//
public abstract class TestPOA
extends org.omg.PortableServer.Servant
implements org.omg.CORBA.portable.InvokeHandler,
TestOperations
{
static final String[] _ob_ids_ =
{
"IDL:Test:1.0",
};
public Test
_this()
{
return TestHelper.narrow(super._this_object());
}
public Test
_this(org.omg.CORBA.ORB orb)
{
return TestHelper.narrow(super._this_object(orb));
}
public String[]
_all_interfaces(org.omg.PortableServer.POA poa, byte[] objectId)
{
return _ob_ids_;
}
public org.omg.CORBA.portable.OutputStream
_invoke(String opName,
org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
final String[] _ob_names =
{
"aMethod"
};
int _ob_left = 0;
int _ob_right = _ob_names.length;
int _ob_index = -1;
while(_ob_left < _ob_right)
{
int _ob_m = (_ob_left + _ob_right) / 2;
int _ob_res = _ob_names[_ob_m].compareTo(opName);
if(_ob_res == 0)
{
_ob_index = _ob_m;
break;
}
else if(_ob_res > 0)
_ob_right = _ob_m;
else
_ob_left = _ob_m + 1;
}
if(_ob_index == -1 && opName.charAt(0) == '_')
{
_ob_left = 0;
_ob_right = _ob_names.length;
String _ob_ami_op =
opName.substring(1);
while(_ob_left < _ob_right)
{
int _ob_m = (_ob_left + _ob_right) / 2;
int _ob_res = _ob_names[_ob_m].compareTo(_ob_ami_op);
if(_ob_res == 0)
{
_ob_index = _ob_m;
break;
}
else if(_ob_res > 0)
_ob_right = _ob_m;
else
_ob_left = _ob_m + 1;
}
}
switch(_ob_index)
{
case 0: // aMethod
return _OB_op_aMethod(in, handler);
}
throw new org.omg.CORBA.BAD_OPERATION();
}
private org.omg.CORBA.portable.OutputStream
_OB_op_aMethod(org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
org.omg.CORBA.portable.OutputStream out = null;
aMethod();
out = handler.createReply();
return out;
}
}
| 5,764 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestCreate.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
import org.omg.PortableServer.POAManagerPackage.*;
public final class TestCreate extends test.common.TestBase {
static void run(ORB orb, POA root) {
org.omg.CORBA.Object obj;
Policy[] policies = new Policy[0];
POA poa, parent, poa2, poa3;
POAManager mgr;
String str;
POAManager rootMgr = root.the_POAManager();
assertTrue(rootMgr != null);
//
// Test: POAManager should be in HOLDING state
//
assertTrue(rootMgr.get_state() == State.HOLDING);
//
// Create child POA
//
try {
poa = root.create_POA("poa1", null, policies);
} catch (InvalidPolicy ex) {
throw new RuntimeException();
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
}
//
// Test: POAManager should NOT be the same as the root's manager
//
mgr = poa.the_POAManager();
assertTrue(!mgr._is_equivalent(rootMgr));
//
// Test: POAManager should be in HOLDING state
//
assertTrue(mgr.get_state() == State.HOLDING);
//
// Test: Confirm name
//
str = poa.the_name();
assertTrue(str.equals("poa1"));
//
// Test: Confirm parent
//
parent = poa.the_parent();
assertTrue(parent._is_equivalent(root));
//
// Test: AdapterAlreadyExists exception
//
try {
poa2 = root.create_POA("poa1", null, policies);
assertTrue(false); // create_POA should not have succeeded
} catch (AdapterAlreadyExists ex) {
// expected
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
//
// Test: InvalidPolicy exception
//
Policy[] invalidpolicies = new Policy[1];
invalidpolicies[0] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.NON_RETAIN);
try {
poa2 = root.create_POA("invalid", null, invalidpolicies);
assertTrue(false); // create_POA should not have succeeded
} catch (InvalidPolicy ex) {
// expected
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
}
//
// Create another child of root POA
//
try {
poa2 = root.create_POA("poa2", rootMgr, policies);
} catch (InvalidPolicy ex) {
throw new RuntimeException();
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
}
//
// Test: POAManager should be the same as the root's manager
//
mgr = poa2.the_POAManager();
assertTrue(mgr._is_equivalent(rootMgr));
//
// Create child of child POA
//
try {
poa3 = poa2.create_POA("child", rootMgr, policies);
} catch (InvalidPolicy ex) {
throw new RuntimeException();
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
}
//
// Test: Confirm parent
//
parent = poa3.the_parent();
assertTrue(parent._is_equivalent(poa2));
poa.destroy(true, true);
poa2.destroy(true, true);
}
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
int status = 0;
ORB orb = null;
try {
//
// Create ORB
//
orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
//
// Run the test
//
System.out.print("Testing POA::create_POA()... ");
System.out.flush();
run(orb, root);
System.out.println("Done!");
} catch (SystemException ex) {
ex.printStackTrace();
status = 1;
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
status = 1;
}
}
System.exit(status);
}
}
| 5,765 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/_TestServerStub.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestServer:1.0
//
public class _TestServerStub extends org.omg.CORBA.portable.ObjectImpl
implements TestServer
{
private static final String[] _ob_ids_ =
{
"IDL:TestServer:1.0",
};
public String[]
_ids()
{
return _ob_ids_;
}
final public static java.lang.Class _ob_opsClass = TestServerOperations.class;
//
// IDL:TestServer/get_info:1.0
//
public TestInfo[]
get_info()
{
while(true)
{
if(!this._is_local())
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.portable.InputStream in = null;
try
{
out = _request("get_info", true);
in = _invoke(out);
TestInfo[] _ob_r = TestInfoSeqHelper.read(in);
return _ob_r;
}
catch(org.omg.CORBA.portable.RemarshalException _ob_ex)
{
continue;
}
catch(org.omg.CORBA.portable.ApplicationException _ob_aex)
{
final String _ob_id = _ob_aex.getId();
in = _ob_aex.getInputStream();
throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: " + _ob_id);
}
finally
{
_releaseReply(in);
}
}
else
{
org.omg.CORBA.portable.ServantObject _ob_so = _servant_preinvoke("get_info", _ob_opsClass);
if(_ob_so == null)
continue;
TestServerOperations _ob_self = (TestServerOperations)_ob_so.servant;
try
{
return _ob_self.get_info();
}
finally
{
_servant_postinvoke(_ob_so);
}
}
}
}
//
// IDL:TestServer/deactivate:1.0
//
public void
deactivate()
{
while(true)
{
if(!this._is_local())
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.portable.InputStream in = null;
try
{
out = _request("deactivate", true);
in = _invoke(out);
return;
}
catch(org.omg.CORBA.portable.RemarshalException _ob_ex)
{
continue;
}
catch(org.omg.CORBA.portable.ApplicationException _ob_aex)
{
final String _ob_id = _ob_aex.getId();
in = _ob_aex.getInputStream();
throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: " + _ob_id);
}
finally
{
_releaseReply(in);
}
}
else
{
org.omg.CORBA.portable.ServantObject _ob_so = _servant_preinvoke("deactivate", _ob_opsClass);
if(_ob_so == null)
continue;
TestServerOperations _ob_self = (TestServerOperations)_ob_so.servant;
try
{
_ob_self.deactivate();
return;
}
finally
{
_servant_postinvoke(_ob_so);
}
}
}
}
}
| 5,766 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestServantActivator.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
import java.io.*;
import java.util.Properties;
final class TestServantActivator {
final static class TestActivator_impl extends ServantActivatorPOA {
private ORB orb_;
TestActivator_impl(ORB orb) {
orb_ = orb;
}
public Servant incarnate(byte[] oid, POA poa) throws ForwardRequest {
String oidString = new String(oid);
//
// If the user is requesting the object "test" then oblige
//
Servant servant = null;
if (oidString.equals("test"))
servant = new Test_impl(orb_, "test", false);
else if (oidString.equals("testDSI"))
servant = new TestDSIRef_impl(orb_, "", false);
if (servant != null) {
//
// Verify that POA allows activator to explicitly activate
// a servant
//
try {
poa.activate_object_with_id(oid, servant);
} catch (ObjectAlreadyActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantAlreadyActive ex) {
throw new RuntimeException();
}
return servant;
}
//
// Fail
//
throw new OBJECT_NOT_EXIST();
}
public void etherealize(byte[] oid, POA poa, Servant servant,
boolean cleanup, boolean remaining) {
if (!remaining) {
String oidString = new String(oid);
//
// If the user is requesting the object "test" then oblige.
//
if (oidString.equals("test"))
servant = null;
else if (oidString.equals("testDSI"))
; // Do nothing here
}
}
}
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
try {
ORB orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
POAManager manager = root.the_POAManager();
Policy[] policies = new Policy[3];
policies[0] = root
.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[1] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
policies[2] = root
.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
POA persistentPOA = null;
try {
persistentPOA = root
.create_POA("persistent", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
TestActivator_impl activatorImpl = new TestActivator_impl(orb);
ServantActivator activator = activatorImpl._this(orb);
try {
persistentPOA.set_servant_manager(activator);
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
//
// Create three references, two good and one bad
//
byte[] oid1 = ("test").getBytes();
byte[] oid2 = ("testDSI").getBytes();
byte[] oid3 = ("test2").getBytes();
org.omg.CORBA.Object reference1 = persistentPOA
.create_reference_with_id(oid1, "IDL:Test:1.0");
org.omg.CORBA.Object reference2 = persistentPOA
.create_reference_with_id(oid2, "IDL:Test:1.0");
org.omg.CORBA.Object reference3 = persistentPOA
.create_reference_with_id(oid3, "IDL:Test:1.0");
//
// Create server
//
TestInfo[] info = new TestInfo[3];
info[0] = new TestInfo();
info[0].obj = TestHelper.narrow(reference1);
info[0].except_id = "";
info[1] = new TestInfo();
info[1].obj = TestHelper.narrow(reference2);
info[1].except_id = "";
info[2] = new TestInfo();
info[2].obj = TestHelper.narrow(reference3);
info[2].except_id = "IDL:omg.org/CORBA/OBJECT_NOT_EXIST:1.0";
TestServer_impl serverImpl = new TestServer_impl(orb, info);
TestServer server = serverImpl._this(orb);
//
// Save reference
//
String refFile = "Test.ref";
try {
FileOutputStream file = new FileOutputStream(refFile);
PrintWriter out = new PrintWriter(file);
out.println(orb.object_to_string(server));
out.flush();
file.close();
} catch (IOException ex) {
System.err.println("Can't write to `" + ex.getMessage() + "'");
System.exit(1);
}
//
// Run implementation
//
try {
manager.activate();
} catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
throw new RuntimeException();
}
orb.run();
File file = new File(refFile);
file.delete();
} catch (SystemException ex) {
System.err.println(ex.getMessage());
ex.printStackTrace();
System.exit(1);
}
}
}
| 5,767 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestMisc.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
public final class TestMisc extends test.common.TestBase {
static void TestCreateReference(ORB orb, POA root) {
org.omg.CORBA.Object obj;
POA user, system;
byte[] id1, id2, tmpid;
Policy[] policies;
POAManager manager = root.the_POAManager();
policies = new Policy[1];
policies[0] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
try {
user = root.create_POA("user_id", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
policies = new Policy[1];
policies[0] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.SYSTEM_ID);
try {
system = root.create_POA("system_id", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
//
// Test: create_reference with wrong POA policies
//
try {
obj = user.create_reference("IDL:Test:1.0");
assertTrue(false); // create_reference should not have succeeded
} catch (WrongPolicy ex) {
// expected
}
//
// Test: create_reference - should get a new ID for each invocation
// on POA w/ SYSTEM_ID policy
//
try {
obj = system.create_reference("IDL:Test:1.0");
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(obj != null);
try {
id1 = system.reference_to_id(obj);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (WrongAdapter ex) {
throw new RuntimeException();
}
try {
obj = system.create_reference("IDL:Test:1.0");
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(obj != null);
try {
id2 = system.reference_to_id(obj);
} catch (WrongAdapter ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(!TestUtil.Compare(id1, id2));
//
// Test: create_reference_with_id using a system-generated ID
//
try {
obj = system.create_reference_with_id(id1, "IDL:Test:1.0");
} catch (BAD_PARAM ex) {
assertTrue(false); // create_reference_with_id should have succeeded
}
id1 = ("id1").getBytes();
//
// Test: create_reference_with_id using a user-generated ID
//
try {
obj = system.create_reference_with_id(id1, "IDL:Test:1.0");
assertTrue(false); // create_reference_with_id should have not
// succeeded
} catch (BAD_PARAM ex) {
// Expected
}
//
// Test: create_reference_with_id
//
obj = user.create_reference_with_id(id1, "IDL:Test:1.0");
assertTrue(obj != null);
try {
tmpid = user.reference_to_id(obj);
} catch (WrongAdapter ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(TestUtil.Compare(id1, tmpid));
id2 = ("id2").getBytes();
obj = user.create_reference_with_id(id2, "IDL:Test:1.0");
assertTrue(obj != null);
try {
tmpid = user.reference_to_id(obj);
} catch (WrongAdapter ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(TestUtil.Compare(id2, tmpid));
user.destroy(true, true);
system.destroy(true, true);
}
static void TestServantToId(ORB orb, POA root) {
org.omg.CORBA.Object obj;
POA unique, implicit, multiple;
byte[] id1, id2, tmpid;
Policy[] policies;
Test_impl servant1;
Test_impl servant2;
POAManager manager = root.the_POAManager();
//
// Create POA w/ UNIQUE_ID, NO_IMPLICIT_ACTIVATION
//
policies = new Policy[4];
policies[0] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
policies[1] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
policies[2] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[3] = root
.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
try {
unique = root.create_POA("unique_id", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
//
// Create POA w/ UNIQUE_ID, IMPLICIT_ACTIVATION
//
policies = new Policy[3];
policies[0] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
policies[1] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[2] = root
.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
try {
implicit = root.create_POA("implicit", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
//
// Create POA w/ MULTIPLE_ID, IMPLICIT_ACTIVATION
//
policies = new Policy[3];
policies[0] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
policies[1] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[2] = root
.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
try {
multiple = root.create_POA("multiple", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
servant1 = new Test_impl(orb, "test1", false);
servant2 = new Test_impl(orb, "test2", false);
//
// Test: ServantNotActive exception
//
try {
unique.servant_to_id(servant1);
assertTrue(false); // servant_to_id should not have succeeded
} catch (ServantNotActive ex) {
// expected
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
id1 = ("test1").getBytes();
try {
unique.activate_object_with_id(id1, servant1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantAlreadyActive ex) {
throw new RuntimeException();
} catch (ObjectAlreadyActive ex) {
throw new RuntimeException();
}
//
// Test: servant_to_id (UNIQUE_ID policy)
//
try {
tmpid = unique.servant_to_id(servant1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantNotActive ex) {
throw new RuntimeException();
}
assertTrue(TestUtil.Compare(id1, tmpid));
//
// Test: servant_to_id (IMPLICIT_ACTIVATION) - servant1 should
// be automatically activated
//
try {
id1 = implicit.servant_to_id(servant1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantNotActive ex) {
throw new RuntimeException();
}
//
// Test: Now that servant1 is activated, and since we have UNIQUE_ID,
// we should get the same ID back
//
try {
tmpid = implicit.servant_to_id(servant1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantNotActive ex) {
throw new RuntimeException();
}
assertTrue(TestUtil.Compare(id1, tmpid));
//
// Test: Implicitly activating servant2 should produce a new ID
//
try {
id2 = implicit.servant_to_id(servant2);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantNotActive ex) {
throw new RuntimeException();
}
assertTrue(!TestUtil.Compare(id1, id2));
//
// Test: servant_to_id (IMPLICIT_ACTIVATION, MULTIPLE_ID) - servant1
// should be automatically activated
//
try {
id1 = multiple.servant_to_id(servant1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantNotActive ex) {
throw new RuntimeException();
}
//
// Test: Since we have MULTIPLE_ID, we should get a new ID
//
try {
tmpid = multiple.servant_to_id(servant1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantNotActive ex) {
throw new RuntimeException();
}
assertTrue(!TestUtil.Compare(id1, tmpid));
unique.destroy(true, true);
implicit.destroy(true, true);
multiple.destroy(true, true);
}
static void TestIdToServant(ORB orb, POA root) {
org.omg.CORBA.Object obj;
POA retain, defaultPOA;
byte[] id1, id2, tmpid;
Policy[] policies;
Test_impl def;
Test_impl servant1;
Test_impl servant2;
Servant tmpservant;
POAManager manager = root.the_POAManager();
//
// Create POA w/ RETAIN
//
policies = new Policy[3];
policies[0] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[1] = root
.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[2] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
try {
retain = root.create_POA("retain", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
//
// Create POA w/ USE_DEFAULT_SERVANT
//
policies = new Policy[5];
policies[0] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
policies[1] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[2] = root
.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_DEFAULT_SERVANT);
policies[3] = root
.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[4] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
try {
defaultPOA = root.create_POA("default", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
def = new Test_impl(orb, "default", false);
try {
defaultPOA.set_servant(def);
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
servant1 = new Test_impl(orb, "test1", false);
servant2 = new Test_impl(orb, "test2", false);
//
// Test: ObjectNotActive exception
//
try {
tmpid = ("bad_id").getBytes();
retain.id_to_servant(tmpid);
assertTrue(false); // id_to_servant should not have succeeded
} catch (ObjectNotActive ex) {
// expected
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
id1 = ("test1").getBytes();
id2 = ("test2").getBytes();
try {
retain.activate_object_with_id(id1, servant1);
retain.activate_object_with_id(id2, servant2);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantAlreadyActive ex) {
throw new RuntimeException();
} catch (ObjectAlreadyActive ex) {
throw new RuntimeException();
}
//
// Test: servant_to_id (RETAIN policy)
//
try {
tmpservant = retain.id_to_servant(id1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ObjectNotActive ex) {
throw new RuntimeException();
}
assertTrue(servant1 == tmpservant);
try {
tmpservant = retain.id_to_servant(id2);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ObjectNotActive ex) {
throw new RuntimeException();
}
assertTrue(servant2 == tmpservant);
//
// Test: id_to_servant (USE_DEFAULT_SERVANT)
//
try {
defaultPOA.activate_object_with_id(id1, servant1);
defaultPOA.activate_object_with_id(id2, servant2);
} catch (ServantAlreadyActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ObjectAlreadyActive ex) {
throw new RuntimeException();
}
try {
tmpservant = defaultPOA.id_to_servant(id1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ObjectNotActive ex) {
throw new RuntimeException();
}
assertTrue(servant1 == tmpservant);
try {
tmpservant = defaultPOA.id_to_servant(id2);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ObjectNotActive ex) {
throw new RuntimeException();
}
assertTrue(servant2 == tmpservant);
//
// Test: id_to_servant (USE_DEFAULT_SERVANT) - should return
// default servant for all unknown IDs
//
tmpid = ("test99").getBytes();
try {
tmpservant = defaultPOA.id_to_servant(tmpid);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ObjectNotActive ex) {
throw new RuntimeException();
}
assertTrue(tmpservant == def);
tmpservant = null;
retain.destroy(true, true);
defaultPOA.destroy(true, true);
}
static void TestServantToReference(ORB orb, POA root) {
org.omg.CORBA.Object obj;
POA unique, implicit, multiple;
byte[] id1, id2, tmpid1, tmpid2;
Policy[] policies;
Test_impl servant1;
Test_impl servant2;
POAManager manager = root.the_POAManager();
//
// Create POA w/ UNIQUE_ID, NO_IMPLICIT_ACTIVATION
//
policies = new Policy[4];
policies[0] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
policies[1] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
policies[2] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[3] = root
.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
try {
unique = root.create_POA("unique_id", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
//
// Create POA w/ UNIQUE_ID, IMPLICIT_ACTIVATION
//
policies = new Policy[3];
policies[0] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
policies[1] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[2] = root
.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
try {
implicit = root.create_POA("implicit", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
//
// Create POA w/ MULTIPLE_ID, IMPLICIT_ACTIVATION
//
policies = new Policy[3];
policies[0] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
policies[1] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[2] = root
.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
try {
multiple = root.create_POA("multiple", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
servant1 = new Test_impl(orb, "test1", false);
servant2 = new Test_impl(orb, "test2", false);
//
// Test: ServantNotActive exception
//
try {
unique.servant_to_reference(servant1);
assertTrue(false); // servant_to_reference should not have succeeded
} catch (ServantNotActive ex) {
// expected
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
id1 = ("test1").getBytes();
try {
unique.activate_object_with_id(id1, servant1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantAlreadyActive ex) {
throw new RuntimeException();
} catch (ObjectAlreadyActive ex) {
throw new RuntimeException();
}
//
// Test: servant_to_reference (UNIQUE_ID policy)
//
try {
obj = unique.servant_to_reference(servant1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantNotActive ex) {
throw new RuntimeException();
}
assertTrue(obj != null);
try {
tmpid1 = unique.reference_to_id(obj);
} catch (WrongAdapter ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(TestUtil.Compare(id1, tmpid1));
//
// Test: servant_to_reference (IMPLICIT_ACTIVATION) - servant1 should
// be automatically activated
//
try {
obj = implicit.servant_to_reference(servant1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantNotActive ex) {
throw new RuntimeException();
}
assertTrue(obj != null);
try {
tmpid1 = implicit.reference_to_id(obj);
} catch (WrongAdapter ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
//
// Test: Now that servant1 is activated, and since we have UNIQUE_ID,
// we should get the same ID back
//
try {
obj = implicit.servant_to_reference(servant1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantNotActive ex) {
throw new RuntimeException();
}
assertTrue(obj != null);
try {
tmpid2 = implicit.reference_to_id(obj);
} catch (WrongAdapter ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(TestUtil.Compare(tmpid1, tmpid2));
//
// Test: Implicitly activating servant2 should produce a new ID
//
try {
obj = implicit.servant_to_reference(servant2);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantNotActive ex) {
throw new RuntimeException();
}
assertTrue(obj != null);
try {
tmpid2 = implicit.reference_to_id(obj);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (WrongAdapter ex) {
throw new RuntimeException();
}
assertTrue(!TestUtil.Compare(tmpid1, tmpid2));
//
// Test: servant_to_reference (IMPLICIT_ACTIVATION, MULTIPLE_ID) -
// servant1 should be automatically activated
//
try {
obj = multiple.servant_to_reference(servant1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantNotActive ex) {
throw new RuntimeException();
}
assertTrue(obj != null);
try {
tmpid1 = multiple.reference_to_id(obj);
} catch (WrongAdapter ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
//
// Test: Since we have MULTIPLE_ID, we should get a new ID
//
try {
obj = multiple.servant_to_reference(servant1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantNotActive ex) {
throw new RuntimeException();
}
assertTrue(obj != null);
try {
tmpid2 = multiple.reference_to_id(obj);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (WrongAdapter ex) {
throw new RuntimeException();
}
assertTrue(!TestUtil.Compare(tmpid1, tmpid2));
unique.destroy(true, true);
implicit.destroy(true, true);
multiple.destroy(true, true);
}
static void TestIdToReference(ORB orb, POA root) {
org.omg.CORBA.Object obj;
POA retain, defaultPOA;
byte[] id1, id2, tmpid;
Policy[] policies;
Test_impl servant1;
Test_impl servant2;
POAManager manager = root.the_POAManager();
//
// Create POA w/ RETAIN
//
policies = new Policy[3];
policies[0] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[1] = root
.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[2] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
try {
retain = root.create_POA("retain", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
servant1 = new Test_impl(orb, "test1", false);
servant2 = new Test_impl(orb, "test2", false);
//
// Test: ObjectNotActive exception
//
try {
tmpid = ("bad_id").getBytes();
retain.id_to_reference(tmpid);
assertTrue(false); // id_to_reference should not have succeeded
} catch (ObjectNotActive ex) {
// expected
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
id1 = ("test1").getBytes();
id2 = ("test2").getBytes();
try {
retain.activate_object_with_id(id1, servant1);
retain.activate_object_with_id(id2, servant2);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantAlreadyActive ex) {
throw new RuntimeException();
} catch (ObjectAlreadyActive ex) {
throw new RuntimeException();
}
//
// Test: servant_to_reference
//
try {
obj = retain.id_to_reference(id1);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ObjectNotActive ex) {
throw new RuntimeException();
}
assertTrue(obj != null);
try {
tmpid = retain.reference_to_id(obj);
} catch (WrongAdapter ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(TestUtil.Compare(id1, tmpid));
//
// Test: servant_to_reference
//
try {
obj = retain.id_to_reference(id2);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ObjectNotActive ex) {
throw new RuntimeException();
}
assertTrue(obj != null);
try {
tmpid = retain.reference_to_id(obj);
} catch (WrongAdapter ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(TestUtil.Compare(id2, tmpid));
retain.destroy(true, true);
}
static void TestReferenceToServant(ORB orb, POA root) {
org.omg.CORBA.Object obj;
POA retain, defaultPOA;
byte[] id1, id2, tmpid;
Policy[] policies;
Test_impl def;
Test_impl servant1;
Test_impl servant2;
Servant tmpservant;
POAManager manager = root.the_POAManager();
//
// Create POA w/ RETAIN
//
policies = new Policy[3];
policies[0] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[1] = root
.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[2] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
try {
retain = root.create_POA("retain", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
//
// Create POA w/ USE_DEFAULT_SERVANT
//
policies = new Policy[5];
policies[0] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
policies[1] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[2] = root
.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_DEFAULT_SERVANT);
policies[3] = root
.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[4] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
try {
defaultPOA = root.create_POA("default", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
def = new Test_impl(orb, "default", false);
try {
defaultPOA.set_servant(def);
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
servant1 = new Test_impl(orb, "test1", false);
servant2 = new Test_impl(orb, "test2", false);
//
// Test: ObjectNotActive exception
//
try {
tmpid = ("bad_id").getBytes();
obj = retain.create_reference_with_id(tmpid, "IDL:Test:1.0");
retain.reference_to_servant(obj);
assertTrue(false); // reference_to_servant should not have succeeded
} catch (ObjectNotActive ex) {
// expected
} catch (WrongAdapter ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
id1 = ("test1").getBytes();
id2 = ("test2").getBytes();
try {
retain.activate_object_with_id(id1, servant1);
retain.activate_object_with_id(id2, servant2);
} catch (ObjectAlreadyActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantAlreadyActive ex) {
throw new RuntimeException();
}
//
// Test: reference_to_servant (RETAIN policy)
//
obj = retain.create_reference_with_id(id1, "IDL:Test:1.0");
try {
tmpservant = retain.reference_to_servant(obj);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (WrongAdapter ex) {
throw new RuntimeException();
}
assertTrue(servant1 == tmpservant);
obj = retain.create_reference_with_id(id2, "IDL:Test:1.0");
try {
tmpservant = retain.reference_to_servant(obj);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (WrongAdapter ex) {
throw new RuntimeException();
}
assertTrue(servant2 == tmpservant);
//
// Test: WrongAdapter exception
//
try {
obj = retain.create_reference_with_id(id1, "IDL:Test:1.0");
defaultPOA.reference_to_servant(obj);
assertTrue(false); // reference_to_servant should not have succeeded
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (WrongAdapter ex) {
// expected
}
//
// Test: reference_to_servant (USE_DEFAULT_SERVANT)
//
try {
defaultPOA.activate_object_with_id(id1, servant1);
defaultPOA.activate_object_with_id(id2, servant2);
} catch (ObjectAlreadyActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ServantAlreadyActive ex) {
throw new RuntimeException();
}
obj = defaultPOA.create_reference_with_id(id1, "IDL:Test:1.0");
try {
tmpservant = defaultPOA.reference_to_servant(obj);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongAdapter ex) {
throw new RuntimeException();
}
assertTrue(servant1 == tmpservant);
obj = defaultPOA.create_reference_with_id(id2, "IDL:Test:1.0");
try {
tmpservant = defaultPOA.reference_to_servant(obj);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongAdapter ex) {
throw new RuntimeException();
}
assertTrue(servant2 == tmpservant);
//
// Test: reference_to_servant (USE_DEFAULT_SERVANT) - should return
// default servant for all unknown IDs
//
tmpid = ("test99").getBytes();
obj = defaultPOA.create_reference_with_id(tmpid, "IDL:Test:1.0");
try {
tmpservant = defaultPOA.reference_to_servant(obj);
} catch (WrongPolicy ex) {
throw new RuntimeException();
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongAdapter ex) {
throw new RuntimeException();
}
assertTrue(tmpservant == def);
tmpservant = null;
retain.destroy(true, true);
defaultPOA.destroy(true, true);
}
static void TestReferenceToId(ORB orb, POA root) {
org.omg.CORBA.Object obj;
POA poa;
byte[] id1, id2, tmpid;
Policy[] policies;
POAManager manager = root.the_POAManager();
//
// Create POA
//
policies = new Policy[3];
policies[0] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[1] = root
.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[2] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
try {
poa = root.create_POA("poa", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
id1 = ("test1").getBytes();
id2 = ("test2").getBytes();
//
// Test: reference_to_id
//
obj = poa.create_reference_with_id(id1, "IDL:Test:1.0");
try {
tmpid = poa.reference_to_id(obj);
} catch (WrongAdapter ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(TestUtil.Compare(tmpid, id1));
obj = poa.create_reference_with_id(id2, "IDL:Test:1.0");
try {
tmpid = poa.reference_to_id(obj);
} catch (WrongAdapter ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
assertTrue(TestUtil.Compare(tmpid, id2));
//
// Test: WrongAdapter exception
//
try {
obj = poa.create_reference_with_id(id1, "IDL:Test:1.0");
root.reference_to_id(obj);
assertTrue(false); // reference_to_id should not have succeeded
} catch (WrongAdapter ex) {
// expected
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
poa.destroy(true, true);
}
static void runtests(ORB orb, POA root) {
TestCreateReference(orb, root);
TestServantToId(orb, root);
TestIdToServant(orb, root);
TestServantToReference(orb, root);
TestIdToReference(orb, root);
TestReferenceToServant(orb, root);
TestReferenceToId(orb, root);
}
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
int status = 0;
ORB orb = null;
try {
//
// Create ORB
//
orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
System.out.print("Testing miscellaneous POA functions... ");
System.out.flush();
//
// Run the tests using the root POA
//
runtests(orb, root);
//
// Create a child POA and run the tests again using the
// child as the root
//
Policy[] policies = new Policy[0];
POAManager manager = root.the_POAManager();
POA child = null;
try {
child = root.create_POA("child", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
runtests(orb, child);
System.out.println("Done!");
} catch (SystemException ex) {
ex.printStackTrace();
status = 1;
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
status = 1;
}
}
System.exit(status);
}
}
| 5,768 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestMultipleOrbsThreadedClient.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import java.util.*;
final public class TestMultipleOrbsThreadedClient extends test.common.TestBase {
public static void main(String args[]) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
org.omg.CORBA.ORB orb = null;
try {
//
// Create ORB
//
orb = org.omg.CORBA.ORB.init(args, props);
//
// Get test servers object references
//
org.omg.CORBA.Object obj = orb
.string_to_object("relfile:/Test.ref");
if (obj == null) {
System.err.println("TestMultipleOrbsClient: "
+ "cannot read IOR from Test.ref");
System.exit(1);
}
TestServer server = TestServerHelper.narrow(obj);
assertTrue(server != null);
TestInfo[] info = server.get_info();
//
// Call a few methods on each object
//
for (int idx = 0; idx < 3; idx++) {
for (int idx2 = 0; idx2 < info.length; idx2++) {
// try
// {
info[idx2].obj.aMethod();
// }
// catch(org.omg.CORBA.TRANSIENT)
// {
// TODO: for now since shutdown can cause a
// TRANSIENT exception on the client.
// _OB_assert(idx == 2);
// }
}
}
//
// Deactivate servers
//
server.deactivate();
} catch (org.omg.CORBA.SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
if (orb != null) {
try {
orb.destroy();
} catch (org.omg.CORBA.SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
System.exit(0);
}
}
| 5,769 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestOperations.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:Test:1.0
//
/***/
public interface TestOperations
{
//
// IDL:Test/aMethod:1.0
//
/***/
void
aMethod();
}
| 5,770 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/POAManagerProxyHelper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:POAManagerProxy:1.0
//
final public class POAManagerProxyHelper
{
public static void
insert(org.omg.CORBA.Any any, POAManagerProxy val)
{
any.insert_Object(val, type());
}
public static POAManagerProxy
extract(org.omg.CORBA.Any any)
{
if(any.type().equivalent(type()))
return narrow(any.extract_Object());
throw new org.omg.CORBA.BAD_OPERATION();
}
private static org.omg.CORBA.TypeCode typeCode_;
public static org.omg.CORBA.TypeCode
type()
{
if(typeCode_ == null)
{
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
typeCode_ = orb.create_interface_tc(id(), "POAManagerProxy");
}
return typeCode_;
}
public static String
id()
{
return "IDL:POAManagerProxy:1.0";
}
public static POAManagerProxy
read(org.omg.CORBA.portable.InputStream in)
{
org.omg.CORBA.Object _ob_v = in.read_Object();
try
{
return (POAManagerProxy)_ob_v;
}
catch(ClassCastException ex)
{
}
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)_ob_v;
_POAManagerProxyStub _ob_stub = new _POAManagerProxyStub();
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
public static void
write(org.omg.CORBA.portable.OutputStream out, POAManagerProxy val)
{
out.write_Object(val);
}
public static POAManagerProxy
narrow(org.omg.CORBA.Object val)
{
if(val != null)
{
try
{
return (POAManagerProxy)val;
}
catch(ClassCastException ex)
{
}
if(val._is_a(id()))
{
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_POAManagerProxyStub _ob_stub = new _POAManagerProxyStub();
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)val;
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
throw new org.omg.CORBA.BAD_PARAM();
}
return null;
}
public static POAManagerProxy
unchecked_narrow(org.omg.CORBA.Object val)
{
if(val != null)
{
try
{
return (POAManagerProxy)val;
}
catch(ClassCastException ex)
{
}
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_POAManagerProxyStub _ob_stub = new _POAManagerProxyStub();
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)val;
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
return null;
}
}
| 5,771 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestServerPOA.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestServer:1.0
//
public abstract class TestServerPOA
extends org.omg.PortableServer.Servant
implements org.omg.CORBA.portable.InvokeHandler,
TestServerOperations
{
static final String[] _ob_ids_ =
{
"IDL:TestServer:1.0",
};
public TestServer
_this()
{
return TestServerHelper.narrow(super._this_object());
}
public TestServer
_this(org.omg.CORBA.ORB orb)
{
return TestServerHelper.narrow(super._this_object(orb));
}
public String[]
_all_interfaces(org.omg.PortableServer.POA poa, byte[] objectId)
{
return _ob_ids_;
}
public org.omg.CORBA.portable.OutputStream
_invoke(String opName,
org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
final String[] _ob_names =
{
"deactivate",
"get_info"
};
int _ob_left = 0;
int _ob_right = _ob_names.length;
int _ob_index = -1;
while(_ob_left < _ob_right)
{
int _ob_m = (_ob_left + _ob_right) / 2;
int _ob_res = _ob_names[_ob_m].compareTo(opName);
if(_ob_res == 0)
{
_ob_index = _ob_m;
break;
}
else if(_ob_res > 0)
_ob_right = _ob_m;
else
_ob_left = _ob_m + 1;
}
if(_ob_index == -1 && opName.charAt(0) == '_')
{
_ob_left = 0;
_ob_right = _ob_names.length;
String _ob_ami_op =
opName.substring(1);
while(_ob_left < _ob_right)
{
int _ob_m = (_ob_left + _ob_right) / 2;
int _ob_res = _ob_names[_ob_m].compareTo(_ob_ami_op);
if(_ob_res == 0)
{
_ob_index = _ob_m;
break;
}
else if(_ob_res > 0)
_ob_right = _ob_m;
else
_ob_left = _ob_m + 1;
}
}
switch(_ob_index)
{
case 0: // deactivate
return _OB_op_deactivate(in, handler);
case 1: // get_info
return _OB_op_get_info(in, handler);
}
throw new org.omg.CORBA.BAD_OPERATION();
}
private org.omg.CORBA.portable.OutputStream
_OB_op_deactivate(org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
org.omg.CORBA.portable.OutputStream out = null;
deactivate();
out = handler.createReply();
return out;
}
private org.omg.CORBA.portable.OutputStream
_OB_op_get_info(org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
org.omg.CORBA.portable.OutputStream out = null;
TestInfo[] _ob_r = get_info();
out = handler.createReply();
TestInfoSeqHelper.write(out, _ob_r);
return out;
}
}
| 5,772 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestLocationForwardServerHolder.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestLocationForwardServer:1.0
//
final public class TestLocationForwardServerHolder implements org.omg.CORBA.portable.Streamable
{
public TestLocationForwardServer value;
public
TestLocationForwardServerHolder()
{
}
public
TestLocationForwardServerHolder(TestLocationForwardServer initial)
{
value = initial;
}
public void
_read(org.omg.CORBA.portable.InputStream in)
{
value = TestLocationForwardServerHelper.read(in);
}
public void
_write(org.omg.CORBA.portable.OutputStream out)
{
TestLocationForwardServerHelper.write(out, value);
}
public org.omg.CORBA.TypeCode
_type()
{
return TestLocationForwardServerHelper.type();
}
}
| 5,773 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestFind.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
public final class TestFind extends test.common.TestBase {
static void run(ORB orb, POA root) {
org.omg.CORBA.Object obj;
Policy[] policies = new Policy[0];
POA poa, parent, poa2, poa3;
POAManager mgr;
String str;
POAManager rootMgr = root.the_POAManager();
assertTrue(rootMgr != null);
//
// Create child POA
//
try {
poa = root.create_POA("poa1", rootMgr, policies);
} catch (InvalidPolicy ex) {
throw new RuntimeException();
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
}
//
// Test: find_POA
//
try {
poa2 = root.find_POA("poa1", false);
} catch (AdapterNonExistent ex) {
throw new RuntimeException();
}
assertTrue(poa2 != null);
assertTrue(poa2._is_equivalent(poa));
//
// Test: AdapterNonExistent exception
//
try {
poa2 = root.find_POA("poaX", false);
assertTrue(false); // find_POA should not have succeeded
} catch (AdapterNonExistent ex) {
// expected
}
//
// Create child POA
//
try {
poa2 = root.create_POA("poa2", rootMgr, policies);
} catch (InvalidPolicy ex) {
throw new RuntimeException();
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
}
//
// Test: Confirm parent knows about child
//
try {
poa3 = root.find_POA("poa2", false);
} catch (AdapterNonExistent ex) {
throw new RuntimeException();
}
assertTrue(poa3 != null);
assertTrue(poa3._is_equivalent(poa2));
}
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
int status = 0;
ORB orb = null;
try {
//
// Create ORB
//
orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
//
// Run the test
//
System.out.print("Testing POA::find_POA... ");
System.out.flush();
run(orb, root);
System.out.println("Done!");
} catch (SystemException ex) {
ex.printStackTrace();
status = 1;
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
status = 1;
}
}
System.exit(status);
}
}
| 5,774 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestCollocated.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
import org.omg.PortableServer.ServantLocatorPackage.*;
public final class TestCollocated extends test.common.TestBase {
final static class TestLocator_impl extends ServantLocatorPOA {
private ORB orb_;
private Test_impl test_;
private TestDSIRef_impl testDSI_;
TestLocator_impl(ORB orb) {
orb_ = orb;
test_ = new Test_impl(orb, "locator_SSI", false);
testDSI_ = new TestDSIRef_impl(orb, "locator_DSI", false);
}
public Servant preinvoke(byte[] oid, POA poa, String operation,
CookieHolder the_cookie) throws ForwardRequest {
String oidString = new String(oid);
if (oidString.equals("test"))
return test_;
else if (oidString.equals("testDSI"))
return testDSI_;
return null;
}
public void postinvoke(byte[] oid, POA poa, String operation,
java.lang.Object the_cookie, Servant the_servant) {
}
}
final static class TestActivator_impl extends ServantActivatorPOA {
private ORB orb_;
private Test_impl test_;
private TestDSIRef_impl testDSI_;
TestActivator_impl(ORB orb) {
orb_ = orb;
test_ = new Test_impl(orb, "locator_SSI", false);
testDSI_ = new TestDSIRef_impl(orb, "locator_DSI", false);
}
public Servant incarnate(byte[] oid, POA poa) throws ForwardRequest {
String oidString = new String(oid);
if (oidString.equals("test"))
return test_;
else if (oidString.equals("testDSI"))
return testDSI_;
//
// Fail
//
return null;
}
public void etherealize(byte[] oid, POA poa, Servant servant,
boolean cleanup, boolean remaining) {
String oidString = new String(oid);
if (!remaining) {
if (oidString.equals("test")) {
servant = null;
test_ = null;
} else if (oidString.equals("testDSI")) {
testDSI_ = null;
}
}
}
}
static void TestPOA(POA poa) {
byte[] id;
org.omg.CORBA.Object obj;
Request request;
Test test;
//
// Invoke twice on each object - statically & DII
//
id = ("test").getBytes();
obj = poa.create_reference_with_id(id, "IDL:Test:1.0");
test = TestHelper.narrow(obj);
test.aMethod();
request = obj._request("aMethod");
request.invoke();
assertTrue(request.env().exception() == null);
id = ("testDSI").getBytes();
obj = poa.create_reference_with_id(id, "IDL:Test:1.0");
test = TestHelper.narrow(obj);
test.aMethod();
request = obj._request("aMethod");
request.invoke();
assertTrue(request.env().exception() == null);
}
static void TestDefaultServant(ORB orb, POA root, POAManager manager) {
POA poa;
Servant servant;
Policy[] policies;
//
// Setup policies for default servant
//
policies = new Policy[6];
policies[0] = root
.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[1] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
policies[2] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.NON_RETAIN);
policies[3] = root
.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
policies[4] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
policies[5] = root
.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_DEFAULT_SERVANT);
//
// Create POA w/ static Default Servant
//
try {
poa = root.create_POA("defaultSSI", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
Test_impl staticServant = new Test_impl(orb, "defaultStaticServant",
false);
try {
poa.set_servant(staticServant);
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
TestPOA(poa);
poa.destroy(true, true);
//
// Since staticServant is a stack-based servant, we need to deactivate
// it before it goes out of scope
//
byte[] id = null;
try {
id = root.servant_to_id(staticServant);
} catch (ServantNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
try {
root.deactivate_object(id);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
//
// Create POA w/ DSI Default Servant
//
try {
poa = root.create_POA("defaultDSI", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
servant = new TestDSIRef_impl(orb, "defaultDSIServant", false);
try {
poa.set_servant(servant);
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
TestPOA(poa);
poa.destroy(true, true);
servant = null;
//
// Clean up policies
//
for (int i = 0; i < policies.length; i++)
policies[i].destroy();
}
static void TestServantLocator(ORB orb, POA root, POAManager manager) {
POA poa;
Servant servant;
Policy[] policies;
//
// Setup policies for servant locator
//
policies = new Policy[6];
policies[0] = root
.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[1] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
policies[2] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.NON_RETAIN);
policies[3] = root
.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
policies[4] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
policies[5] = root
.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
//
// Create POA w/ Servant Locator
//
try {
poa = root.create_POA("servloc", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
TestLocator_impl locatorImpl = new TestLocator_impl(orb);
ServantLocator locator = locatorImpl._this(orb);
try {
poa.set_servant_manager(locator);
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
TestPOA(poa);
poa.destroy(true, true);
//
// Clean up policies
//
for (int i = 0; i < policies.length; i++)
policies[i].destroy();
//
// Since locatorImpl is a stack-based servant, we need to deactivate
// it before it goes out of scope
//
byte[] id = null;
try {
id = root.servant_to_id(locatorImpl);
} catch (ServantNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
try {
root.deactivate_object(id);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
}
static void TestServantActivator(ORB orb, POA root, POAManager manager) {
POA poa;
Servant servant;
Policy[] policies;
//
// Setup policies for servant activator
//
policies = new Policy[6];
policies[0] = root
.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[1] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
policies[2] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[3] = root
.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
policies[4] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
policies[5] = root
.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER);
//
// Create POA w/ Servant Activator
//
try {
poa = root.create_POA("servant", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
TestActivator_impl activatorImpl = new TestActivator_impl(orb);
ServantActivator activator = activatorImpl._this(orb);
try {
poa.set_servant_manager(activator);
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
TestPOA(poa);
poa.destroy(true, true);
//
// Clean up policies
//
for (int i = 0; i < policies.length; i++)
policies[i].destroy();
//
// Since activatorImpl is a stack-based servant, we need to deactivate
// it before it goes out of scope
//
byte[] id = null;
try {
id = root.servant_to_id(activatorImpl);
} catch (ServantNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
try {
root.deactivate_object(id);
} catch (ObjectNotActive ex) {
throw new RuntimeException();
} catch (WrongPolicy ex) {
throw new RuntimeException();
}
}
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
ORB orb = null;
try {
orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
POAManager manager = root.the_POAManager();
try {
manager.activate();
} catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
throw new RuntimeException();
}
System.out.print("Testing collocated default servant... ");
System.out.flush();
TestDefaultServant(orb, root, manager);
System.out.println("Done!");
System.out.print("Testing collocated servant locator... ");
System.out.flush();
TestServantLocator(orb, root, manager);
System.out.println("Done!");
System.out.print("Testing collocated servant activator... ");
System.out.flush();
TestServantActivator(orb, root, manager);
System.out.println("Done!");
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
System.exit(0);
}
}
| 5,775 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestMultipleOrbsServer.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import java.util.Properties;
import java.io.*;
final public class TestMultipleOrbsServer extends test.common.TestBase {
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
org.omg.CORBA.ORB orb1 = null;
org.omg.CORBA.ORB orb2 = null;
try {
//
// Create ORB
//
orb1 = org.omg.CORBA.ORB.init(args, props);
orb2 = org.omg.CORBA.ORB.init(args, props);
//
// Resolve Root POA and POA Manager
//
org.omg.CORBA.Object poaObj = orb1
.resolve_initial_references("RootPOA");
org.omg.PortableServer.POA rootPOA1 = org.omg.PortableServer.POAHelper
.narrow(poaObj);
org.omg.PortableServer.POAManager manager1 = rootPOA1
.the_POAManager();
poaObj = orb2.resolve_initial_references("RootPOA");
org.omg.PortableServer.POA rootPOA2 = org.omg.PortableServer.POAHelper
.narrow(poaObj);
org.omg.PortableServer.POAManager manager2 = rootPOA2
.the_POAManager();
//
// Create test implementation object in each ORB
//
Test_impl testImpl1 = new Test_impl(orb1, rootPOA1);
;
Test test1 = testImpl1._this(orb1);
Test_impl testImpl2 = new Test_impl(orb2, rootPOA2);
;
Test test2 = testImpl2._this(orb2);
//
// Create Test Server in each ORB
//
TestInfo[] info = new TestInfo[1];
info[0] = new TestInfo();
info[0].obj = test1;
info[0].except_id = "";
TestServer_impl serverImpl1 = new TestServer_impl(orb1, info);
TestServer server1 = serverImpl1._this(orb1);
info[0].obj = test2;
info[0].except_id = "";
TestServer_impl serverImpl2 = new TestServer_impl(orb2, info);
TestServer server2 = serverImpl2._this(orb2);
//
// Save references
//
String refFile = "Test.ref";
try {
FileOutputStream file = new FileOutputStream(refFile);
PrintWriter out = new PrintWriter(file);
out.println(orb1.object_to_string(server1));
out.println(orb2.object_to_string(server2));
out.flush();
file.close();
} catch (IOException ex) {
System.err.println("Can't write to `" + ex.getMessage() + "'");
System.exit(1);
}
//
// Run implementation
//
manager1.activate();
manager2.activate();
boolean orb1_gone = false;
boolean orb2_gone = false;
for (;;) {
try {
if (orb1.work_pending())
orb1.perform_work();
} catch (org.omg.CORBA.BAD_INV_ORDER ex) {
orb1_gone = true;
}
try {
if (orb2.work_pending())
orb2.perform_work();
} catch (org.omg.CORBA.BAD_INV_ORDER ex) {
orb2_gone = true;
}
if (orb1_gone && orb2_gone)
break;
}
File file = new File(refFile);
file.delete();
} catch (org.omg.CORBA.SystemException ex) {
ex.printStackTrace();
System.exit(1);
} catch (org.omg.CORBA.UserException ex) {
ex.printStackTrace();
System.exit(1);
}
if (orb1 != null) {
try {
((org.apache.yoko.orb.CORBA.ORB) orb1).destroy();
} catch (org.omg.CORBA.SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
if (orb2 != null) {
try {
((org.apache.yoko.orb.CORBA.ORB) orb2).destroy();
} catch (org.omg.CORBA.SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
System.exit(0);
}
}
| 5,776 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestPOAManagerCommon.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
import java.util.concurrent.CountDownLatch;
final class TestPOAManagerCommon extends test.common.TestBase {
final static class TestHoldingState extends Thread {
private Test test_;
private final CountDownLatch startLatch = new CountDownLatch(1);
public volatile Result result = null;
public enum Result { SUCCESS, FAILURE, ERROR };
TestHoldingState(Test test) {
test_ = test;
}
public void run() {
startLatch.countDown();
try {
test_.aMethod();
result = Result.SUCCESS;
} catch (TRANSIENT ex) {
result = Result.FAILURE;
return;
} catch (SystemException ex) {
result = Result.ERROR;
System.err.println("Unexpected: " + ex);
ex.printStackTrace();
}
}
public void waitForStart() {
do {
try {
startLatch.await();
return;
} catch (InterruptedException e) {
}
} while (true);
}
public void waitForEnd() {
while (isAlive()) {
try {
join();
} catch (java.lang.InterruptedException e) {
}
}
}
}
TestPOAManagerCommon(POAManagerProxy manager, TestInfo[] info) {
for (int i = 0; i < info.length; i++) {
try {
manager.activate();
} catch (test.poa.POAManagerProxyPackage.AdapterInactive ex) {
assertTrue(false);
}
info[i].obj.aMethod();
//
// Try discard_request with wait completion == true,
// shouldn't work since the discard_request call is done
// through the POAManagerProxy.
//
try {
manager.discard_requests(true);
assertTrue(false);
} catch (test.poa.POAManagerProxyPackage.AdapterInactive ex) {
assertTrue(false);
} catch (org.omg.CORBA.BAD_INV_ORDER e) {
// Expected, ensure the state didn't change
assertTrue(manager.get_state() == test.poa.POAManagerProxyPackage.State.ACTIVE);
}
//
// Test discard_requests when active.
//
try {
manager.discard_requests(false);
assertTrue(manager.get_state() == test.poa.POAManagerProxyPackage.State.DISCARDING);
} catch (test.poa.POAManagerProxyPackage.AdapterInactive ex) {
assertTrue(false);
}
try {
info[i].obj.aMethod();
assertTrue(false);
} catch (TRANSIENT ex) {
// Expected
}
try {
manager.activate();
} catch (test.poa.POAManagerProxyPackage.AdapterInactive ex) {
assertTrue(false);
}
info[i].obj.aMethod();
//
// Try hold_request with wait completion == true,
// shouldn't work since the hold_request call is done
// through the POAManagerProxy.
//
try {
manager.hold_requests(true);
assertTrue(false);
} catch (test.poa.POAManagerProxyPackage.AdapterInactive ex) {
assertTrue(false);
} catch (org.omg.CORBA.BAD_INV_ORDER e) {
// Expected, ensure the state didn't change
assertTrue(manager.get_state() == test.poa.POAManagerProxyPackage.State.ACTIVE);
}
//
// Test hold_requests when active.
//
try {
manager.hold_requests(false);
assertTrue(manager.get_state() == test.poa.POAManagerProxyPackage.State.HOLDING);
} catch (test.poa.POAManagerProxyPackage.AdapterInactive ex) {
assertTrue(false);
}
TestHoldingState t = new TestHoldingState(info[i].obj);
t.start();
t.waitForStart();
try {
manager.activate();
} catch (test.poa.POAManagerProxyPackage.AdapterInactive ex) {
assertTrue(false);
}
t.waitForEnd();
assertTrue(t.result == TestHoldingState.Result.SUCCESS);
//
// Test discard_requests when holding.
//
try {
manager.hold_requests(false);
assertTrue(manager.get_state() == test.poa.POAManagerProxyPackage.State.HOLDING);
} catch (test.poa.POAManagerProxyPackage.AdapterInactive ex) {
assertTrue(false);
}
t = new TestHoldingState(info[i].obj);
t.start();
t.waitForStart();
try {
manager.discard_requests(false);
assertTrue(manager.get_state() == test.poa.POAManagerProxyPackage.State.DISCARDING);
} catch (test.poa.POAManagerProxyPackage.AdapterInactive ex) {
assertTrue(false);
}
try {
info[i].obj.aMethod();
assertTrue(false);
} catch (TRANSIENT ex) {
// Expected
}
t.waitForEnd();
//
// Queued call should have been discarded.
//
assertTrue(t.result == TestHoldingState.Result.FAILURE);
//
// Test hold_requests when discarding.
//
try {
manager.hold_requests(false);
assertTrue(manager.get_state() == test.poa.POAManagerProxyPackage.State.HOLDING);
} catch (test.poa.POAManagerProxyPackage.AdapterInactive ex) {
assertTrue(false);
}
t = new TestHoldingState(info[i].obj);
t.start();
t.waitForStart();
try {
manager.activate();
} catch (test.poa.POAManagerProxyPackage.AdapterInactive ex) {
assertTrue(false);
}
t.waitForEnd();
assertTrue(t.result == TestHoldingState.Result.SUCCESS);
//
// Try deactivate with wait completion == true,
// shouldn't work since the hold_request call is done
// through the POAManagerProxy.
//
try {
manager.deactivate(true, true);
assertTrue(false);
} catch (test.poa.POAManagerProxyPackage.AdapterInactive ex) {
assertTrue(false);
} catch (org.omg.CORBA.BAD_INV_ORDER e) {
// Expected, ensure the state didn't change
assertTrue(manager.get_state() == test.poa.POAManagerProxyPackage.State.ACTIVE);
}
}
}
}
| 5,777 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestLocationForwardServerHelper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestLocationForwardServer:1.0
//
final public class TestLocationForwardServerHelper
{
public static void
insert(org.omg.CORBA.Any any, TestLocationForwardServer val)
{
any.insert_Object(val, type());
}
public static TestLocationForwardServer
extract(org.omg.CORBA.Any any)
{
if(any.type().equivalent(type()))
return narrow(any.extract_Object());
throw new org.omg.CORBA.BAD_OPERATION();
}
private static org.omg.CORBA.TypeCode typeCode_;
public static org.omg.CORBA.TypeCode
type()
{
if(typeCode_ == null)
{
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
typeCode_ = orb.create_interface_tc(id(), "TestLocationForwardServer");
}
return typeCode_;
}
public static String
id()
{
return "IDL:TestLocationForwardServer:1.0";
}
public static TestLocationForwardServer
read(org.omg.CORBA.portable.InputStream in)
{
org.omg.CORBA.Object _ob_v = in.read_Object();
try
{
return (TestLocationForwardServer)_ob_v;
}
catch(ClassCastException ex)
{
}
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)_ob_v;
_TestLocationForwardServerStub _ob_stub = new _TestLocationForwardServerStub();
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
public static void
write(org.omg.CORBA.portable.OutputStream out, TestLocationForwardServer val)
{
out.write_Object(val);
}
public static TestLocationForwardServer
narrow(org.omg.CORBA.Object val)
{
if(val != null)
{
try
{
return (TestLocationForwardServer)val;
}
catch(ClassCastException ex)
{
}
if(val._is_a(id()))
{
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_TestLocationForwardServerStub _ob_stub = new _TestLocationForwardServerStub();
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)val;
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
throw new org.omg.CORBA.BAD_PARAM();
}
return null;
}
public static TestLocationForwardServer
unchecked_narrow(org.omg.CORBA.Object val)
{
if(val != null)
{
try
{
return (TestLocationForwardServer)val;
}
catch(ClassCastException ex)
{
}
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_TestLocationForwardServerStub _ob_stub = new _TestLocationForwardServerStub();
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)val;
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
return null;
}
}
| 5,778 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/POAManagerProxyHolder.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:POAManagerProxy:1.0
//
final public class POAManagerProxyHolder implements org.omg.CORBA.portable.Streamable
{
public POAManagerProxy value;
public
POAManagerProxyHolder()
{
}
public
POAManagerProxyHolder(POAManagerProxy initial)
{
value = initial;
}
public void
_read(org.omg.CORBA.portable.InputStream in)
{
value = POAManagerProxyHelper.read(in);
}
public void
_write(org.omg.CORBA.portable.OutputStream out)
{
POAManagerProxyHelper.write(out, value);
}
public org.omg.CORBA.TypeCode
_type()
{
return POAManagerProxyHelper.type();
}
}
| 5,779 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestLocationForwardServerOperations.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestLocationForwardServer:1.0
//
/***/
public interface TestLocationForwardServerOperations
{
//
// IDL:TestLocationForwardServer/setForwardRequest:1.0
//
/***/
void
setForwardRequest(org.omg.CORBA.Object obj);
//
// IDL:TestLocationForwardServer/get_servant:1.0
//
/***/
org.omg.CORBA.Object
get_servant();
//
// IDL:TestLocationForwardServer/deactivate:1.0
//
/***/
void
deactivate();
}
| 5,780 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestPOAManagerFactory.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
import org.omg.PortableServer.POAManagerFactoryPackage.*;
import java.lang.System;
final class TestPOAManagerFactory extends test.common.TestBase {
static void TestAll(ORB orb, POA root) {
POAManagerFactory factory = root.the_POAManagerFactory();
org.apache.yoko.orb.OBPortableServer.POAManagerFactory pmFactory = org.apache.yoko.orb.OBPortableServer.POAManagerFactoryHelper
.narrow(factory);
POAManager[] managers;
//
// Initial count: RootPOAManager
//
int count = 1;
managers = pmFactory.list();
assertTrue(managers.length == 1);
//
// Create POA Managers without policies
//
Policy[] pl = new Policy[0];
;
POAManager test = null;
try {
test = pmFactory.create_POAManager("TestPOAManager", pl);
count++;
} catch (ManagerAlreadyExists ex) {
assertTrue(false);
} catch (PolicyError ex) {
}
POAManager tmp = pmFactory.find("TestPOAManager");
assertTrue(tmp == test);
managers = pmFactory.list();
//
// count == 2
//
assertTrue(count == 2);
assertTrue(managers.length == count);
POAManager test2 = null;
try {
test2 = pmFactory.create_POAManager("TestPOAManager2", pl);
count++;
} catch (ManagerAlreadyExists ex) {
assertTrue(false);
} catch (PolicyError ex) {
}
tmp = pmFactory.find("TestPOAManager2");
assertTrue(tmp == test2);
managers = pmFactory.list();
//
// count == 3
//
assertTrue(count == 3);
assertTrue(managers.length == count);
try {
test2 = pmFactory.create_POAManager("TestPOAManager2", pl);
count++;
//
// 'create_POAManager' should not have succeeded
//
assertTrue(false);
} catch (ManagerAlreadyExists ex) {
//
// Expected
//
} catch (PolicyError ex) {
}
assertTrue(tmp == test2);
assertTrue(test != test2);
managers = pmFactory.list();
//
// count == 3 (still)
//
assertTrue(count == 3);
assertTrue(managers.length == count);
//
// Create POA Managers with proprietary policies
//
Policy[] policies = new Policy[2];
boolean policiesOkay = true;
try {
policies[0] = pmFactory
.create_communications_concurrency_policy(org.apache.yoko.orb.OBPortableServer.COMMUNICATIONS_CONCURRENCY_POLICY_THREADED.value);
policies[1] = pmFactory
.create_giop_version_policy(org.apache.yoko.orb.OBPortableServer.GIOP_VERSION_POLICY_1_2.value);
} catch (PolicyError ex) {
policiesOkay = false;
}
if (policiesOkay) {
POAManager configManager = null;
try {
configManager = pmFactory.create_POAManager("ConfigManager",
policies);
count++;
} catch (ManagerAlreadyExists ex) {
assertTrue(false);
} catch (PolicyError ex) {
}
tmp = pmFactory.find("ConfigManager");
assertTrue(tmp == configManager);
}
managers = pmFactory.list();
//
// count == 4
//
assertTrue(count == 4);
assertTrue(managers.length == count);
//
// Check the policy values
//
org.apache.yoko.orb.OBPortableServer.CommunicationsConcurrencyPolicy commsPolicy = org.apache.yoko.orb.OBPortableServer.CommunicationsConcurrencyPolicyHelper
.narrow(policies[0]);
assertTrue(commsPolicy.value() == org.apache.yoko.orb.OBPortableServer.COMMUNICATIONS_CONCURRENCY_POLICY_THREADED.value);
assertTrue(commsPolicy.policy_type() == org.apache.yoko.orb.OBPortableServer.COMMUNICATIONS_CONCURRENCY_POLICY_ID.value);
org.apache.yoko.orb.OBPortableServer.GIOPVersionPolicy giopPolicy = org.apache.yoko.orb.OBPortableServer.GIOPVersionPolicyHelper
.narrow(policies[1]);
assertTrue(giopPolicy.value() == org.apache.yoko.orb.OBPortableServer.GIOP_VERSION_POLICY_1_2.value);
assertTrue(giopPolicy.policy_type() == org.apache.yoko.orb.OBPortableServer.GIOP_VERSION_POLICY_ID.value);
//
// EndpointConfigurationPolicy
//
String config = "iiop --host localhost --port 10999 --bind localhost";
Policy[] policies2 = new Policy[1];
policiesOkay = true;
try {
policies2[0] = pmFactory
.create_endpoint_configuration_policy(config);
} catch (PolicyError ex) {
policiesOkay = false;
}
if (policiesOkay) {
org.apache.yoko.orb.OBPortableServer.EndpointConfigurationPolicy endpointPolicy = org.apache.yoko.orb.OBPortableServer.EndpointConfigurationPolicyHelper
.narrow(policies2[0]);
assertTrue(endpointPolicy.policy_type() == org.apache.yoko.orb.OBPortableServer.ENDPOINT_CONFIGURATION_POLICY_ID.value);
//
// Create POA Manager with endpoint policy
//
POAManager endpointManager = null;
try {
endpointManager = pmFactory.create_POAManager(
"EndpointManager", policies2);
count++;
} catch (ManagerAlreadyExists ex) {
assertTrue(false);
} catch (PolicyError ex) {
}
tmp = pmFactory.find("EndpointManager");
assertTrue(tmp == endpointManager);
}
managers = pmFactory.list();
//
// count == 5
//
assertTrue(count == 5);
assertTrue(managers.length == count);
}
static void runtests(ORB orb, POA root) {
TestAll(orb, root);
}
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
int status = 0;
ORB orb = null;
try {
//
// Create ORB
//
orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
System.out.print("Testing POAManagerFactory... ");
System.out.flush();
//
// Run the tests using the root POA
//
runtests(orb, root);
System.out.println("Done!");
} catch (SystemException ex) {
ex.printStackTrace();
status = 1;
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
status = 1;
}
}
System.exit(status);
}
}
| 5,781 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/_TestLocationForwardStub.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestLocationForward:1.0
//
public class _TestLocationForwardStub extends org.omg.CORBA.portable.ObjectImpl
implements TestLocationForward
{
private static final String[] _ob_ids_ =
{
"IDL:TestLocationForward:1.0",
"IDL:Test:1.0"
};
public String[]
_ids()
{
return _ob_ids_;
}
final public static java.lang.Class _ob_opsClass = TestLocationForwardOperations.class;
//
// IDL:TestLocationForward/deactivate_servant:1.0
//
public void
deactivate_servant()
{
while(true)
{
if(!this._is_local())
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.portable.InputStream in = null;
try
{
out = _request("deactivate_servant", true);
in = _invoke(out);
return;
}
catch(org.omg.CORBA.portable.RemarshalException _ob_ex)
{
continue;
}
catch(org.omg.CORBA.portable.ApplicationException _ob_aex)
{
final String _ob_id = _ob_aex.getId();
in = _ob_aex.getInputStream();
throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: " + _ob_id);
}
finally
{
_releaseReply(in);
}
}
else
{
org.omg.CORBA.portable.ServantObject _ob_so = _servant_preinvoke("deactivate_servant", _ob_opsClass);
if(_ob_so == null)
continue;
TestLocationForwardOperations _ob_self = (TestLocationForwardOperations)_ob_so.servant;
try
{
_ob_self.deactivate_servant();
return;
}
finally
{
_servant_postinvoke(_ob_so);
}
}
}
}
//
// IDL:Test/aMethod:1.0
//
public void
aMethod()
{
while(true)
{
if(!this._is_local())
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.portable.InputStream in = null;
try
{
out = _request("aMethod", true);
in = _invoke(out);
return;
}
catch(org.omg.CORBA.portable.RemarshalException _ob_ex)
{
continue;
}
catch(org.omg.CORBA.portable.ApplicationException _ob_aex)
{
final String _ob_id = _ob_aex.getId();
in = _ob_aex.getInputStream();
throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: " + _ob_id);
}
finally
{
_releaseReply(in);
}
}
else
{
org.omg.CORBA.portable.ServantObject _ob_so = _servant_preinvoke("aMethod", _ob_opsClass);
if(_ob_so == null)
continue;
TestLocationForwardOperations _ob_self = (TestLocationForwardOperations)_ob_so.servant;
try
{
_ob_self.aMethod();
return;
}
finally
{
_servant_postinvoke(_ob_so);
}
}
}
}
}
| 5,782 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestServer_impl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import org.omg.CORBA.*;
final class TestServer_impl extends TestServerPOA {
private ORB orb_;
private TestInfo[] info_;
TestServer_impl(ORB orb, TestInfo[] info) {
orb_ = orb;
info_ = info;
}
public TestInfo[] get_info() {
return info_;
}
public void deactivate() {
if (orb_ != null) {
orb_.shutdown(false);
orb_ = null;
}
}
}
| 5,783 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestMultipleOrbsThreadedServer.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import java.io.*;
import java.util.Properties;
final public class TestMultipleOrbsThreadedServer extends test.common.TestBase {
//
// Define the number of ORB instances to run in separate threads.
//
static int NUM_ORBS = 5;
//
// Implementation to test multiple orbs
//
final static class TestOrb_impl extends TestPOA {
private int count_;
private org.omg.CORBA.ORB orb_;
TestOrb_impl(org.omg.CORBA.ORB orb) {
count_ = 0;
orb_ = orb;
}
public void aMethod() {
if (++count_ == 3) {
//
// Shutdown th orb after three method calls
//
orb_.shutdown(false);
}
}
}
static final class OrbTestThread extends Thread {
private org.omg.CORBA.ORB orb_;
private org.omg.PortableServer.POAManager manager_;
private TestOrb_impl test_;
private Test obj_;
OrbTestThread(String orb_id) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props
.put("org.omg.CORBA.ORBClass",
"org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
props.put("yoko.orb.id", orb_id); // Use ORB ID passed
try {
String[] args = new String[0];
orb_ = org.omg.CORBA.ORB.init(args, props);
org.omg.CORBA.Object obj = orb_
.resolve_initial_references("RootPOA");
org.omg.PortableServer.POA rootPOA = org.omg.PortableServer.POAHelper
.narrow(obj);
manager_ = rootPOA.the_POAManager();
test_ = new TestOrb_impl(orb_);
byte[] objId = rootPOA.activate_object(test_);
obj = rootPOA.id_to_reference(objId);
obj_ = TestHelper.narrow(obj);
} catch (org.omg.CORBA.UserException ex) {
System.err.println(ex.getMessage());
ex.printStackTrace();
System.exit(1);
}
}
public Test getObjectReference() {
return obj_;
}
public void run() {
try {
manager_.activate();
orb_.run();
} catch (org.omg.CORBA.SystemException ex) {
ex.printStackTrace();
System.exit(1);
} catch (org.omg.CORBA.UserException ex) {
ex.printStackTrace();
System.exit(1);
}
if (orb_ != null) {
try {
((org.apache.yoko.orb.CORBA.ORB) orb_).destroy();
} catch (org.omg.CORBA.SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
}
}
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
props.put("yoko.orb.id", ""); // Use default ORB
org.omg.CORBA.ORB orb = null;
try {
args = org.apache.yoko.orb.CORBA.ORB.ParseArgs(args, props, null);
props.put("yoko.orb.conc_model", "threaded");
props.put("yoko.orb.oa.conc_model", "threaded");
//
// Create ORB
//
orb = org.omg.CORBA.ORB.init(args, props);
//
// Resolve Root POA and POA Manager
//
org.omg.CORBA.Object poaObj = orb
.resolve_initial_references("RootPOA");
org.omg.PortableServer.POA rootPOA = org.omg.PortableServer.POAHelper
.narrow(poaObj);
org.omg.PortableServer.POAManager manager = rootPOA
.the_POAManager();
//
// Create threads to run other orb instances
//
OrbTestThread orb_thread[] = new OrbTestThread[NUM_ORBS];
for (int i = 0; i < NUM_ORBS; i++) {
orb_thread[i] = new OrbTestThread("orb" + (i + 1));
}
for (int i = 0; i < NUM_ORBS; i++) {
orb_thread[i].start();
}
//
// Create Test Server
//
TestInfo[] info = new TestInfo[NUM_ORBS];
for (int i = 0; i < NUM_ORBS; i++) {
info[i] = new TestInfo();
info[i].obj = orb_thread[i].getObjectReference();
info[i].except_id = "";
}
TestServer_impl serverImpl = new TestServer_impl(orb, info);
TestServer server = serverImpl._this(orb);
//
// Save references
//
String refFile = "Test.ref";
try {
FileOutputStream file = new FileOutputStream(refFile);
PrintWriter out = new PrintWriter(file);
out.println(orb.object_to_string(server));
out.flush();
file.close();
} catch (IOException ex) {
System.err.println("Can't write to `" + ex.getMessage() + "'");
System.exit(1);
}
// Run implementation
//
manager.activate();
orb.run();
//
// Wait for all other threads to be finished
//
for (int i = 0; i < NUM_ORBS; i++) {
while (orb_thread[i].isAlive()) {
try {
orb_thread[i].join();
} catch (java.lang.InterruptedException ex) {
}
}
}
File file = new File(refFile);
file.delete();
} catch (org.omg.CORBA.SystemException ex) {
ex.printStackTrace();
System.exit(1);
} catch (org.omg.CORBA.UserException ex) {
ex.printStackTrace();
System.exit(1);
}
if (orb != null) {
try {
orb.destroy();
} catch (org.omg.CORBA.SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
System.exit(0);
}
}
| 5,784 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/Test.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:Test:1.0
//
/***/
public interface Test extends TestOperations,
org.omg.CORBA.Object,
org.omg.CORBA.portable.IDLEntity
{
}
| 5,785 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestMultipleOrbsClient.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import java.util.*;
import java.io.*;
final public class TestMultipleOrbsClient extends test.common.TestBase {
public static void main(String args[]) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
org.omg.CORBA.ORB orb = null;
try {
//
// Create ORB
//
orb = org.omg.CORBA.ORB.init(args, props);
//
// Get test servers object references
//
BufferedReader in = new BufferedReader(new FileReader("Test.ref"));
String ref1 = in.readLine();
org.omg.CORBA.Object obj = orb.string_to_object(ref1);
if (obj == null) {
System.err.println("TestMultipleOrbsClient: "
+ " cannot read IOR from Test.ref");
System.exit(1);
}
TestServer server1 = TestServerHelper.narrow(obj);
String ref2 = in.readLine();
obj = orb.string_to_object(ref2);
if (obj == null) {
System.err.println("TestMultipleOrbsClient: "
+ " cannot read IOR from Test.ref");
System.exit(1);
}
TestServer server2 = TestServerHelper.narrow(obj);
in.close();
//
// Get object references from servers
//
TestInfo[] info1 = server1.get_info();
TestInfo[] info2 = server2.get_info();
//
// Call a few methods on each object
//
info1[0].obj.aMethod();
info2[0].obj.aMethod();
info1[0].obj.aMethod();
info2[0].obj.aMethod();
//
// Deactivate servers (and thus orbs)
//
server1.deactivate();
server2.deactivate();
} catch (java.io.FileNotFoundException ex) {
System.err.println("TestMultipleOrbsClient: cannot open Test.ref");
System.exit(1);
} catch (java.io.IOException ex) {
System.err.println("TestMultipleOrbsClient: File input error");
System.exit(1);
} catch (org.omg.CORBA.SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
if (orb != null) {
try {
orb.destroy();
} catch (org.omg.CORBA.SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
System.exit(0);
}
}
| 5,786 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestInfo.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestInfo:1.0
//
/***/
final public class TestInfo implements org.omg.CORBA.portable.IDLEntity
{
private static final String _ob_id = "IDL:TestInfo:1.0";
public
TestInfo()
{
}
public
TestInfo(Test obj,
String except_id)
{
this.obj = obj;
this.except_id = except_id;
}
public Test obj;
public String except_id;
}
| 5,787 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestLocationForwardActivator_impl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
final class TestLocationForwardActivator_impl extends
org.omg.PortableServer.ServantActivatorPOA {
private boolean activate_;
private Servant servant_;
private org.omg.CORBA.Object forward_;
TestLocationForwardActivator_impl() {
activate_ = false;
}
public void setActivatedServant(Servant servant) {
servant_ = servant;
}
public void setForwardRequest(org.omg.CORBA.Object forward) {
forward_ = forward;
}
public Servant incarnate(byte[] oid, POA poa) throws ForwardRequest {
activate_ = !activate_;
if (!activate_)
throw new ForwardRequest(forward_);
return servant_;
}
public void etherealize(byte[] oid, POA poa, Servant servant,
boolean cleanup, boolean remaining) {
}
}
| 5,788 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/_TestStub.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:Test:1.0
//
public class _TestStub extends org.omg.CORBA.portable.ObjectImpl
implements Test
{
private static final String[] _ob_ids_ =
{
"IDL:Test:1.0",
};
public String[]
_ids()
{
return _ob_ids_;
}
final public static java.lang.Class _ob_opsClass = TestOperations.class;
//
// IDL:Test/aMethod:1.0
//
public void
aMethod()
{
while(true)
{
if(!this._is_local())
{
org.omg.CORBA.portable.OutputStream out = null;
org.omg.CORBA.portable.InputStream in = null;
try
{
out = _request("aMethod", true);
in = _invoke(out);
return;
}
catch(org.omg.CORBA.portable.RemarshalException _ob_ex)
{
continue;
}
catch(org.omg.CORBA.portable.ApplicationException _ob_aex)
{
final String _ob_id = _ob_aex.getId();
in = _ob_aex.getInputStream();
throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: " + _ob_id);
}
finally
{
_releaseReply(in);
}
}
else
{
org.omg.CORBA.portable.ServantObject _ob_so = _servant_preinvoke("aMethod", _ob_opsClass);
if(_ob_so == null)
continue;
TestOperations _ob_self = (TestOperations)_ob_so.servant;
try
{
_ob_self.aMethod();
return;
}
finally
{
_servant_postinvoke(_ob_so);
}
}
}
}
}
| 5,789 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestServerHelper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestServer:1.0
//
final public class TestServerHelper
{
public static void
insert(org.omg.CORBA.Any any, TestServer val)
{
any.insert_Object(val, type());
}
public static TestServer
extract(org.omg.CORBA.Any any)
{
if(any.type().equivalent(type()))
return narrow(any.extract_Object());
throw new org.omg.CORBA.BAD_OPERATION();
}
private static org.omg.CORBA.TypeCode typeCode_;
public static org.omg.CORBA.TypeCode
type()
{
if(typeCode_ == null)
{
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
typeCode_ = orb.create_interface_tc(id(), "TestServer");
}
return typeCode_;
}
public static String
id()
{
return "IDL:TestServer:1.0";
}
public static TestServer
read(org.omg.CORBA.portable.InputStream in)
{
org.omg.CORBA.Object _ob_v = in.read_Object();
try
{
return (TestServer)_ob_v;
}
catch(ClassCastException ex)
{
}
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)_ob_v;
_TestServerStub _ob_stub = new _TestServerStub();
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
public static void
write(org.omg.CORBA.portable.OutputStream out, TestServer val)
{
out.write_Object(val);
}
public static TestServer
narrow(org.omg.CORBA.Object val)
{
if(val != null)
{
try
{
return (TestServer)val;
}
catch(ClassCastException ex)
{
}
if(val._is_a(id()))
{
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_TestServerStub _ob_stub = new _TestServerStub();
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)val;
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
throw new org.omg.CORBA.BAD_PARAM();
}
return null;
}
public static TestServer
unchecked_narrow(org.omg.CORBA.Object val)
{
if(val != null)
{
try
{
return (TestServer)val;
}
catch(ClassCastException ex)
{
}
org.omg.CORBA.portable.ObjectImpl _ob_impl;
_TestServerStub _ob_stub = new _TestServerStub();
_ob_impl = (org.omg.CORBA.portable.ObjectImpl)val;
_ob_stub._set_delegate(_ob_impl._get_delegate());
return _ob_stub;
}
return null;
}
}
| 5,790 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestServerHolder.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestServer:1.0
//
final public class TestServerHolder implements org.omg.CORBA.portable.Streamable
{
public TestServer value;
public
TestServerHolder()
{
}
public
TestServerHolder(TestServer initial)
{
value = initial;
}
public void
_read(org.omg.CORBA.portable.InputStream in)
{
value = TestServerHelper.read(in);
}
public void
_write(org.omg.CORBA.portable.OutputStream out)
{
TestServerHelper.write(out, value);
}
public org.omg.CORBA.TypeCode
_type()
{
return TestServerHelper.type();
}
}
| 5,791 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/POAManagerProxyPOA.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:POAManagerProxy:1.0
//
public abstract class POAManagerProxyPOA
extends org.omg.PortableServer.Servant
implements org.omg.CORBA.portable.InvokeHandler,
POAManagerProxyOperations
{
static final String[] _ob_ids_ =
{
"IDL:POAManagerProxy:1.0",
};
public POAManagerProxy
_this()
{
return POAManagerProxyHelper.narrow(super._this_object());
}
public POAManagerProxy
_this(org.omg.CORBA.ORB orb)
{
return POAManagerProxyHelper.narrow(super._this_object(orb));
}
public String[]
_all_interfaces(org.omg.PortableServer.POA poa, byte[] objectId)
{
return _ob_ids_;
}
public org.omg.CORBA.portable.OutputStream
_invoke(String opName,
org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
final String[] _ob_names =
{
"activate",
"deactivate",
"discard_requests",
"get_state",
"hold_requests"
};
int _ob_left = 0;
int _ob_right = _ob_names.length;
int _ob_index = -1;
while(_ob_left < _ob_right)
{
int _ob_m = (_ob_left + _ob_right) / 2;
int _ob_res = _ob_names[_ob_m].compareTo(opName);
if(_ob_res == 0)
{
_ob_index = _ob_m;
break;
}
else if(_ob_res > 0)
_ob_right = _ob_m;
else
_ob_left = _ob_m + 1;
}
if(_ob_index == -1 && opName.charAt(0) == '_')
{
_ob_left = 0;
_ob_right = _ob_names.length;
String _ob_ami_op =
opName.substring(1);
while(_ob_left < _ob_right)
{
int _ob_m = (_ob_left + _ob_right) / 2;
int _ob_res = _ob_names[_ob_m].compareTo(_ob_ami_op);
if(_ob_res == 0)
{
_ob_index = _ob_m;
break;
}
else if(_ob_res > 0)
_ob_right = _ob_m;
else
_ob_left = _ob_m + 1;
}
}
switch(_ob_index)
{
case 0: // activate
return _OB_op_activate(in, handler);
case 1: // deactivate
return _OB_op_deactivate(in, handler);
case 2: // discard_requests
return _OB_op_discard_requests(in, handler);
case 3: // get_state
return _OB_op_get_state(in, handler);
case 4: // hold_requests
return _OB_op_hold_requests(in, handler);
}
throw new org.omg.CORBA.BAD_OPERATION();
}
private org.omg.CORBA.portable.OutputStream
_OB_op_activate(org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
org.omg.CORBA.portable.OutputStream out = null;
try
{
activate();
out = handler.createReply();
}
catch(test.poa.POAManagerProxyPackage.AdapterInactive _ob_ex)
{
out = handler.createExceptionReply();
test.poa.POAManagerProxyPackage.AdapterInactiveHelper.write(out, _ob_ex);
}
return out;
}
private org.omg.CORBA.portable.OutputStream
_OB_op_deactivate(org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
org.omg.CORBA.portable.OutputStream out = null;
try
{
boolean _ob_a0 = in.read_boolean();
boolean _ob_a1 = in.read_boolean();
deactivate(_ob_a0, _ob_a1);
out = handler.createReply();
}
catch(test.poa.POAManagerProxyPackage.AdapterInactive _ob_ex)
{
out = handler.createExceptionReply();
test.poa.POAManagerProxyPackage.AdapterInactiveHelper.write(out, _ob_ex);
}
return out;
}
private org.omg.CORBA.portable.OutputStream
_OB_op_discard_requests(org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
org.omg.CORBA.portable.OutputStream out = null;
try
{
boolean _ob_a0 = in.read_boolean();
discard_requests(_ob_a0);
out = handler.createReply();
}
catch(test.poa.POAManagerProxyPackage.AdapterInactive _ob_ex)
{
out = handler.createExceptionReply();
test.poa.POAManagerProxyPackage.AdapterInactiveHelper.write(out, _ob_ex);
}
return out;
}
private org.omg.CORBA.portable.OutputStream
_OB_op_get_state(org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
org.omg.CORBA.portable.OutputStream out = null;
test.poa.POAManagerProxyPackage.State _ob_r = get_state();
out = handler.createReply();
test.poa.POAManagerProxyPackage.StateHelper.write(out, _ob_r);
return out;
}
private org.omg.CORBA.portable.OutputStream
_OB_op_hold_requests(org.omg.CORBA.portable.InputStream in,
org.omg.CORBA.portable.ResponseHandler handler)
{
org.omg.CORBA.portable.OutputStream out = null;
try
{
boolean _ob_a0 = in.read_boolean();
hold_requests(_ob_a0);
out = handler.createReply();
}
catch(test.poa.POAManagerProxyPackage.AdapterInactive _ob_ex)
{
out = handler.createExceptionReply();
test.poa.POAManagerProxyPackage.AdapterInactiveHelper.write(out, _ob_ex);
}
return out;
}
}
| 5,792 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/POAManagerProxy.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:POAManagerProxy:1.0
//
/***/
public interface POAManagerProxy extends POAManagerProxyOperations,
org.omg.CORBA.Object,
org.omg.CORBA.portable.IDLEntity
{
}
| 5,793 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestDefaultServantServer.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
import java.io.*;
public final class TestDefaultServantServer {
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
ORB orb = null;
try {
//
// Create ORB
//
orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
POAManager manager = root.the_POAManager();
Policy[] policies = new Policy[6];
policies[0] = root
.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
policies[1] = root
.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
policies[2] = root
.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_DEFAULT_SERVANT);
policies[3] = root
.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
policies[4] = root
.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
policies[5] = root
.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
POA persistentPOA = null;
try {
persistentPOA = root
.create_POA("persistent", manager, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
//
// Use a DSI servant as the default
//
TestDSIRef_impl defaultServant = new TestDSIRef_impl(orb, "", false);
defaultServant.setDefaultServant(true);
try {
persistentPOA.set_servant(defaultServant);
} catch (org.omg.PortableServer.POAPackage.WrongPolicy ex) {
throw new RuntimeException();
}
//
// Create some servants
//
Test_impl test1 = new Test_impl(orb, "test1", false);
Test_impl test2 = new Test_impl(orb, "test2", false);
//
// Create ObjectIds
//
byte[] oid1 = ("test1").getBytes();
byte[] oid2 = ("test2").getBytes();
byte[] oid3 = ("testDefault").getBytes();
//
// Activate servants
//
try {
persistentPOA.activate_object_with_id(oid1, test1);
persistentPOA.activate_object_with_id(oid2, test2);
} catch (org.omg.PortableServer.POAPackage.ObjectAlreadyActive ex) {
throw new RuntimeException();
} catch (org.omg.PortableServer.POAPackage.ServantAlreadyActive ex) {
throw new RuntimeException();
} catch (org.omg.PortableServer.POAPackage.WrongPolicy ex) {
throw new RuntimeException();
}
//
// Create object references
//
org.omg.CORBA.Object reference1 = persistentPOA
.create_reference_with_id(oid1, "IDL:Test:1.0");
org.omg.CORBA.Object reference2 = persistentPOA
.create_reference_with_id(oid2, "IDL:Test:1.0");
org.omg.CORBA.Object reference3 = persistentPOA
.create_reference_with_id(oid3, "IDL:Test:1.0");
//
// Create server
//
TestInfo[] info = new TestInfo[3];
info[0] = new TestInfo();
info[1] = new TestInfo();
info[2] = new TestInfo();
info[0].obj = TestHelper.narrow(reference1);
info[0].except_id = "";
info[1].obj = TestHelper.narrow(reference2);
info[1].except_id = "";
info[2].obj = TestHelper.narrow(reference3);
info[2].except_id = "";
TestServer_impl serverImpl = new TestServer_impl(orb, info);
TestServer server = serverImpl._this(orb);
//
// Save reference
//
String refFile = "Test.ref";
try {
FileOutputStream file = new FileOutputStream(refFile);
PrintWriter out = new PrintWriter(file);
out.println(orb.object_to_string(server));
out.flush();
file.close();
} catch (IOException ex) {
System.err.println("Can't write to `" + ex.getMessage() + "'");
System.exit(1);
}
//
// Run implementation
//
try {
manager.activate();
} catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) {
throw new RuntimeException();
}
orb.run();
File file = new File(refFile);
file.delete();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
System.exit(0);
}
}
| 5,794 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestServerOperations.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestServer:1.0
//
/***/
public interface TestServerOperations
{
//
// IDL:TestServer/get_info:1.0
//
/***/
TestInfo[]
get_info();
//
// IDL:TestServer/deactivate:1.0
//
/***/
void
deactivate();
}
| 5,795 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestUtil.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
final class TestUtil {
static POA GetRootPOA(ORB orb) {
org.omg.CORBA.Object obj = null;
try {
obj = orb.resolve_initial_references("RootPOA");
} catch (org.omg.CORBA.ORBPackage.InvalidName ex) {
System.err.println("Error: can't resolve `RootPOA'");
System.exit(1);
}
if (obj == null) {
System.err.println("Error: `RootPOA' is a nil object reference");
System.exit(1);
}
POA root = null;
try {
root = POAHelper.narrow(obj);
} catch (BAD_PARAM ex) {
System.err
.println("Error: `RootPOA' is not a POA object reference");
System.exit(1);
}
return root;
}
static boolean Compare(byte[] id1, byte[] id2) {
//
// TODO: efficient method to doing this?
//
if (id1.length != id2.length)
return false;
for (int i = 0; i < id1.length; i++)
if (id1[i] != id2[i])
return false;
return true;
// return id1.equals(id2);
}
}
| 5,796 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestPOAManagerClient.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
public final class TestPOAManagerClient extends test.common.TestBase {
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
ORB orb = null;
try {
//
// Create ORB
//
orb = ORB.init(args, props);
org.omg.CORBA.Object obj = orb
.string_to_object("relfile:/Test.ref");
if (obj == null) {
System.err.println("cannot read IOR from Test.ref");
System.exit(1);
}
TestServer server = TestServerHelper.narrow(obj);
obj = orb.string_to_object("relfile:/POAManagerProxy.ref");
if (obj == null) {
System.err.println("cannot read IOR from POAManagerProxy.ref");
System.exit(1);
}
POAManagerProxy manager = POAManagerProxyHelper.narrow(obj);
try {
manager.activate();
} catch (test.poa.POAManagerProxyPackage.AdapterInactive ex) {
assertTrue(false);
}
TestInfo[] info = server.get_info();
new TestPOAManagerCommon(manager, info);
server.deactivate();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
System.exit(1);
}
}
System.exit(0);
}
}
| 5,797 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestDestroy.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POAPackage.*;
import org.omg.PortableServer.POAManagerPackage.*;
public final class TestDestroy extends test.common.TestBase {
final static class Test_impl2 extends TestPOA {
private POA poa_;
private boolean called_ = false;
private boolean finished_ = false;
Test_impl2(POA poa) {
poa_ = poa;
}
synchronized public void aMethod() {
called_ = true;
notify();
try {
wait(1000);
} catch (InterruptedException ex) {
}
finished_ = true;
}
public POA _default_POA() {
return poa_;
}
synchronized void blockUntilCalled() {
while (!called_) {
try {
wait();
} catch (InterruptedException ex) {
}
}
}
synchronized boolean callComplete() {
return finished_;
}
}
final static class LongCaller extends Thread {
private Test t_;
LongCaller(Test t) {
t_ = t;
}
public void run() {
try {
t_.aMethod();
} catch (SystemException se) {
System.err.println(se.getMessage());
se.printStackTrace();
}
}
}
//
// This is a more rigorous test of POA::destroy. We want to ensure
// that the POA isn't destroyed during a method call.
//
static void TestDestroyThreaded(ORB orb, POA root) {
POAManager rootMgr = root.the_POAManager();
assertTrue(rootMgr != null);
Policy[] policies = new Policy[1];
policies[0] = root
.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
//
// Create child POA
//
POA poa = null;
try {
poa = root.create_POA("poa1", rootMgr, policies);
} catch (InvalidPolicy ex) {
throw new RuntimeException();
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
}
Test_impl2 impl = new Test_impl2(poa);
Test t = impl._this(orb);
Thread thr = new LongCaller(t);
thr.start();
impl.blockUntilCalled();
//
// Test: Destroy the POA while a method call is active
//
poa.destroy(true, true);
//
// The destroy call shouldn't return until the aMethod call is
// complete
//
assertTrue(impl.callComplete());
while (thr.isAlive()) {
try {
thr.join();
} catch (InterruptedException ex) {
}
}
}
static void TestDestroyBlocking(ORB orb, POA root) {
org.omg.CORBA.Object obj;
Policy[] policies = new Policy[0];
POA poa, parent, poa2, poa3;
POAManager mgr;
String str;
POAManager rootMgr = root.the_POAManager();
assertTrue(rootMgr != null);
//
// Create child POA
//
try {
poa = root.create_POA("poa1", rootMgr, policies);
} catch (InvalidPolicy ex) {
throw new RuntimeException();
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
}
//
// Test: destroy
//
poa.destroy(true, true);
//
// Ensure parent no longer knows about child
//
try {
root.find_POA("poa1", false);
assertTrue(false); // find_POA should not have succeeded
} catch (AdapterNonExistent ex) {
// expected
}
//
// Create child POA
//
try {
poa = root.create_POA("poa1", rootMgr, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
//
// Create child of child POA
//
try {
poa2 = poa.create_POA("child1", rootMgr, policies);
} catch (AdapterAlreadyExists ex) {
throw new RuntimeException();
} catch (InvalidPolicy ex) {
throw new RuntimeException();
}
//
// Test: destroy - should destroy poa1 and poa1/child1
//
poa.destroy(true, true);
//
// Ensure parent no longer knows about child
//
try {
root.find_POA("poa1", false);
assertTrue(false); // find_POA should not have succeeded
} catch (AdapterNonExistent ex) {
// expected
}
//
// XXX Test: etherealize w/ servant manager
//
}
public static void main(String[] args) {
java.util.Properties props = new Properties();
props.putAll(System.getProperties());
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass",
"org.apache.yoko.orb.CORBA.ORBSingleton");
int status = 0;
ORB orb = null;
try {
//
// Create ORB
//
orb = ORB.init(args, props);
POA root = TestUtil.GetRootPOA(orb);
POAManager rootMgr = root.the_POAManager();
assertTrue(rootMgr != null);
try {
rootMgr.activate();
} catch (AdapterInactive ex) {
throw new RuntimeException();
}
System.out.print("Testing POA::destroy... ");
System.out.flush();
TestDestroyBlocking(orb, root);
TestDestroyThreaded(orb, root);
System.out.println("Done!");
} catch (SystemException ex) {
ex.printStackTrace();
status = 1;
}
if (orb != null) {
try {
orb.destroy();
} catch (SystemException ex) {
ex.printStackTrace();
status = 1;
}
}
System.exit(status);
}
}
| 5,798 |
0 | Create_ds/geronimo-yoko/yoko-core/src/test/java/test | Create_ds/geronimo-yoko/yoko-core/src/test/java/test/poa/TestInfoHelper.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.poa;
//
// IDL:TestInfo:1.0
//
final public class TestInfoHelper
{
public static void
insert(org.omg.CORBA.Any any, TestInfo val)
{
org.omg.CORBA.portable.OutputStream out = any.create_output_stream();
write(out, val);
any.read_value(out.create_input_stream(), type());
}
public static TestInfo
extract(org.omg.CORBA.Any any)
{
if(any.type().equivalent(type()))
return read(any.create_input_stream());
else
throw new org.omg.CORBA.BAD_OPERATION();
}
private static org.omg.CORBA.TypeCode typeCode_;
public static org.omg.CORBA.TypeCode
type()
{
if(typeCode_ == null)
{
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
org.omg.CORBA.StructMember[] members = new org.omg.CORBA.StructMember[2];
members[0] = new org.omg.CORBA.StructMember();
members[0].name = "obj";
members[0].type = TestHelper.type();
members[1] = new org.omg.CORBA.StructMember();
members[1].name = "except_id";
members[1].type = orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_string);
typeCode_ = orb.create_struct_tc(id(), "TestInfo", members);
}
return typeCode_;
}
public static String
id()
{
return "IDL:TestInfo:1.0";
}
public static TestInfo
read(org.omg.CORBA.portable.InputStream in)
{
TestInfo _ob_v = new TestInfo();
_ob_v.obj = TestHelper.read(in);
_ob_v.except_id = in.read_string();
return _ob_v;
}
public static void
write(org.omg.CORBA.portable.OutputStream out, TestInfo val)
{
TestHelper.write(out, val.obj);
out.write_string(val.except_id);
}
}
| 5,799 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.